13
0

Add button to Engine Dialog to choose between Portaudio callback and blocking API

This commit is contained in:
Tim Mayberry 2016-02-05 23:32:59 +10:00
parent 85b4acc916
commit 2b4ac72e5d
2 changed files with 60 additions and 0 deletions

View File

@ -87,6 +87,7 @@ EngineControl::EngineControl ()
, midi_devices_button (_("Midi Device Setup"))
, start_stop_button (_("Stop"))
, update_devices_button (_("Refresh Devices"))
, use_buffered_io_button (_("Use Buffered I/O"), ArdourButton::led_default_elements)
, lm_measure_label (_("Measure"))
, lm_use_button (_("Use results"))
, lm_back_button (_("Back to settings ... (ignore results)"))
@ -281,6 +282,11 @@ EngineControl::EngineControl ()
update_devices_button.set_name ("generic button");
update_devices_button.set_can_focus(true);
use_buffered_io_button.signal_clicked.connect (mem_fun (*this, &EngineControl::use_buffered_io_button_clicked));
use_buffered_io_button.set_sensitive (false);
use_buffered_io_button.set_name ("generic button");
use_buffered_io_button.set_can_focus(true);
cancel_button = add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CANCEL);
ok_button = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
@ -503,6 +509,7 @@ EngineControl::build_notebook ()
basic_packer.attach (start_stop_button, 3, 4, 0, 1, xopt, xopt);
basic_packer.attach (update_devices_button, 3, 4, 1, 2, xopt, xopt);
basic_packer.attach (use_buffered_io_button, 3, 4, 2, 3, xopt, xopt);
lm_button_audio.signal_clicked.connect (sigc::mem_fun (*this, &EngineControl::calibrate_audio_latency));
lm_button_audio.set_name ("generic button");
@ -854,14 +861,21 @@ EngineControl::update_sensitivity ()
if (ARDOUR::AudioEngine::instance()->running()) {
start_stop_button.set_text("Stop");
update_devices_button.set_sensitive(false);
use_buffered_io_button.set_sensitive(false);
} else {
if (backend->can_request_update_devices()) {
update_devices_button.show();
} else {
update_devices_button.hide();
}
if (backend->can_use_buffered_io()) {
use_buffered_io_button.show();
} else {
use_buffered_io_button.hide();
}
start_stop_button.set_text("Start");
update_devices_button.set_sensitive(true);
use_buffered_io_button.set_sensitive(true);
}
} else {
update_devices_button.set_sensitive(false);
@ -1823,6 +1837,7 @@ EngineControl::store_state (State state)
state->output_channels = get_output_channels ();
state->midi_option = get_midi_option ();
state->midi_devices = _midi_devices;
state->use_buffered_io = get_use_buffered_io ();
state->lru = time (NULL) ;
}
@ -1852,6 +1867,8 @@ EngineControl::maybe_display_saved_state ()
input_latency.set_value (state->input_latency);
output_latency.set_value (state->output_latency);
use_buffered_io_button.set_active (state->use_buffered_io);
if (!state->midi_option.empty()) {
midi_option_combo.set_active_text (state->midi_option);
_midi_devices = state->midi_devices;
@ -1889,6 +1906,7 @@ EngineControl::get_state ()
node->add_property ("input-channels", (*i)->input_channels);
node->add_property ("output-channels", (*i)->output_channels);
node->add_property ("active", (*i)->active ? "yes" : "no");
node->add_property ("use-buffered-io", (*i)->use_buffered_io ? "yes" : "no");
node->add_property ("midi-option", (*i)->midi_option);
node->add_property ("lru", (*i)->active ? time (NULL) : (*i)->lru);
@ -2033,6 +2051,11 @@ EngineControl::set_state (const XMLNode& root)
}
state->active = string_is_affirmative (prop->value ());
if ((prop = grandchild->property ("use-buffered-io")) == 0) {
continue;
}
state->use_buffered_io = string_is_affirmative (prop->value ());
if ((prop = grandchild->property ("midi-option")) == 0) {
continue;
}
@ -2206,6 +2229,7 @@ EngineControl::set_current_state (const State& state)
input_latency.set_value (state->input_latency);
output_latency.set_value (state->output_latency);
midi_option_combo.set_active_text (state->midi_option);
use_buffered_io_button.set_active (state->use_buffered_io);
return true;
}
@ -2232,6 +2256,7 @@ EngineControl::push_state_to_backend (bool start)
bool change_latency = false;
bool change_channels = false;
bool change_midi = false;
bool change_buffered_io = false;
uint32_t ochan = get_output_channels ();
uint32_t ichan = get_input_channels ();
@ -2282,6 +2307,12 @@ EngineControl::push_state_to_backend (bool start)
change_midi = true;
}
if (backend->can_use_buffered_io()) {
if (get_use_buffered_io() != backend->get_use_buffered_io()) {
change_buffered_io = true;
}
}
/* zero-requested channels means "all available" */
if (ichan == 0) {
@ -2451,6 +2482,10 @@ EngineControl::push_state_to_backend (bool start)
backend->set_midi_option (get_midi_option());
}
if (change_buffered_io) {
backend->set_use_buffered_io (use_buffered_io_button.get_active());
}
if (1 /* TODO */) {
for (vector<MidiDeviceSettings>::const_iterator p = _midi_devices.begin(); p != _midi_devices.end(); ++p) {
if (_measure_midi) {
@ -2565,6 +2600,12 @@ EngineControl::get_midi_option () const
return midi_option_combo.get_active_text();
}
bool
EngineControl::get_use_buffered_io () const
{
return use_buffered_io_button.get_active();
}
uint32_t
EngineControl::get_input_channels() const
{
@ -2675,6 +2716,20 @@ EngineControl::update_devices_button_clicked ()
}
}
void
EngineControl::use_buffered_io_button_clicked ()
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
if (!backend) {
return;
}
bool set_buffered_io = !use_buffered_io_button.get_active();
use_buffered_io_button.set_active (set_buffered_io);
backend->set_use_buffered_io (set_buffered_io);
}
void
EngineControl::manage_control_app_sensitivity ()
{

View File

@ -87,6 +87,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
ArdourButton midi_devices_button;
ArdourButton start_stop_button;
ArdourButton update_devices_button;
ArdourButton use_buffered_io_button;
Gtk::Button connect_disconnect_button;
@ -162,6 +163,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
std::string get_driver() const;
std::string get_backend() const;
std::string get_midi_option () const;
bool get_use_buffered_io () const;
std::string get_default_device (const std::string&,
const std::vector<std::string>&);
@ -222,6 +224,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
uint32_t input_channels;
uint32_t output_channels;
bool active;
bool use_buffered_io;
std::string midi_option;
std::vector<MidiDeviceSettings> midi_devices;
time_t lru;
@ -234,6 +237,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
, input_channels (0)
, output_channels (0)
, active (false)
, use_buffered_io (false)
, lru (0) {}
};
@ -306,6 +310,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
void control_app_button_clicked ();
void start_stop_button_clicked ();
void update_devices_button_clicked ();
void use_buffered_io_button_clicked ();
void use_latency_button_clicked ();
void manage_control_app_sensitivity ();
int push_state_to_backend (bool start);