#include "ardour_ui.h"
#include "engine_dialog.h"
#include "gui_thread.h"
+#include "ui_config.h"
+#include "public_editor.h"
#include "utils.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
+#include "splash.h"
using namespace std;
using namespace Gtk;
, 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)"))
start_stop_button.set_sensitive (false);
start_stop_button.set_name ("generic button");
start_stop_button.set_can_focus(true);
+ start_stop_button.set_can_default(true);
update_devices_button.signal_clicked.connect (mem_fun (*this, &EngineControl::update_devices_button_clicked));
update_devices_button.set_sensitive (false);
update_devices_button.set_name ("generic button");
update_devices_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);
+ 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);
/* Pick up any existing audio setup configuration, if appropriate */
set_default_state ();
}
+ update_sensitivity ();
connect_changed_signals ();
notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
connect_disconnect_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::connect_disconnect_click));
- connect_disconnect_button.set_no_show_all();
+ connect_disconnect_button.set_no_show_all();
+ use_buffered_io_button.set_no_show_all();
+ update_devices_button.set_no_show_all();
+ start_stop_button.set_no_show_all();
+ midi_devices_button.set_no_show_all();
}
void
EngineControl::on_show ()
{
ArdourDialog::on_show ();
+ if (Splash::instance()) {
+ Splash::instance()->hide ();
+ }
if (!ARDOUR::AudioEngine::instance()->current_backend() || !ARDOUR::AudioEngine::instance()->running()) {
// re-check _have_control (jackd running) see #6041
backend_changed ();
}
device_changed ();
- ok_button->grab_focus();
+ start_stop_button.grab_focus();
+}
+
+void
+EngineControl::on_map ()
+{
+ if (!ARDOUR_UI::instance()->session_loaded && !PublicEditor::_instance) {
+ set_type_hint (Gdk::WINDOW_TYPE_HINT_NORMAL);
+ } else if (UIConfiguration::instance().get_all_floating_windows_are_dialogs()) {
+ set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
+ } else {
+ set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
+ }
+ ArdourDialog::on_map ();
+}
+
+bool
+EngineControl::try_autostart ()
+{
+ if (!start_stop_button.get_sensitive()) {
+ return false;
+ }
+ if (ARDOUR::AudioEngine::instance()->running()) {
+ return true;
+ }
+ return start_engine ();
}
bool
return true;
}
-void
-EngineControl::on_response (int response_id)
-{
- ArdourDialog::on_response (response_id);
-
- switch (response_id) {
- case RESPONSE_OK:
- if (!start_engine()) {
- return;
- } else {
- hide();
- }
-#ifdef PLATFORM_WINDOWS
-
- // But if there's no session open, this can produce
- // a long gap when nothing appears to be happening.
- // Let's show the splash image while we're waiting.
- if (!ARDOUR_COMMAND_LINE::no_splash) {
- if (ARDOUR_UI::instance()) {
- if (!ARDOUR_UI::instance()->session_loaded) {
- ARDOUR_UI::instance()->show_splash();
- }
- }
- }
-#endif
- break;
- case RESPONSE_DELETE_EVENT: {
- GdkEventButton ev;
- ev.type = GDK_BUTTON_PRESS;
- ev.button = 1;
- on_delete_event((GdkEventAny*)&ev);
- break;
- }
- case RESPONSE_CANCEL:
- if (ARDOUR_UI::instance() && ARDOUR_UI::instance()->session_loaded) {
- ARDOUR_UI::instance()->check_audioengine(*this);
- }
- // fall through
- default:
- hide();
- }
-}
-
void
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");
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
if (!backend) {
- ok_button->set_sensitive (false);
start_stop_button.set_sensitive (false);
return;
}
}
if (get_popdown_string_count (sample_rate_combo) > 0) {
+ bool allow_to_set_rate = false;
if (!ARDOUR::AudioEngine::instance()->running()) {
- sample_rate_combo.set_sensitive (true);
- } else {
- sample_rate_combo.set_sensitive (false);
+ if (!ARDOUR_UI::instance()->session_loaded) {
+ // engine is not running, no session loaded -> anything goes.
+ allow_to_set_rate = true;
+ } else if (_desired_sample_rate > 0 && get_rate () != _desired_sample_rate) {
+ // only allow to change if the current setting is not the native session rate.
+ allow_to_set_rate = true;
+ }
}
+ sample_rate_combo.set_sensitive (allow_to_set_rate);
} else {
sample_rate_combo.set_sensitive (false);
valid = false;
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);
update_devices_button.hide();
+ use_buffered_io_button.set_sensitive(false);
+ use_buffered_io_button.hide();
start_stop_button.set_sensitive(false);
start_stop_button.hide();
}
driver_combo.set_sensitive (false);
}
}
-
- if (valid || !_have_control) {
- ok_button->set_sensitive (true);
- } else {
- ok_button->set_sensitive (false);
- }
}
void
set_popdown_strings (sample_rate_combo, s);
if (!s.empty()) {
- if (desired.empty ()) {
+ if (ARDOUR::AudioEngine::instance()->running()) {
+ sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
+ }
+ else if (desired.empty ()) {
float new_active_sr = backend->default_sample_rate ();
if (std::find (sr.begin (), sr.end (), new_active_sr) == sr.end ()) {
EngineControl::input_device_changed ()
{
DEBUG_ECONTROL ("input_device_changed");
+
+ boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
+ if (backend && backend->match_input_output_devices_or_none ()) {
+ const std::string& dev_none = ARDOUR::AudioBackend::get_standard_device_name (ARDOUR::AudioBackend::DeviceNone);
+
+ if (get_output_device_name () != dev_none
+ && get_input_device_name () != dev_none
+ && get_input_device_name () != get_output_device_name ()) {
+ block_changed_signals ();
+ if (contains_value (output_device_combo, get_input_device_name ())) {
+ output_device_combo.set_active_text (get_input_device_name ());
+ } else {
+ assert (contains_value (output_device_combo, dev_none));
+ output_device_combo.set_active_text (dev_none);
+ }
+ unblock_changed_signals ();
+ }
+ }
device_changed ();
}
EngineControl::output_device_changed ()
{
DEBUG_ECONTROL ("output_device_changed");
+ boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
+ if (backend && backend->match_input_output_devices_or_none ()) {
+ const std::string& dev_none = ARDOUR::AudioBackend::get_standard_device_name (ARDOUR::AudioBackend::DeviceNone);
+
+ if (get_input_device_name () != dev_none
+ && get_input_device_name () != dev_none
+ && get_input_device_name () != get_output_device_name ()) {
+ block_changed_signals ();
+ if (contains_value (input_device_combo, get_output_device_name ())) {
+ input_device_combo.set_active_text (get_output_device_name ());
+ } else {
+ assert (contains_value (input_device_combo, dev_none));
+ input_device_combo.set_active_text (dev_none);
+ }
+ unblock_changed_signals ();
+ }
+ }
device_changed ();
}
string
EngineControl::bufsize_as_string (uint32_t sz)
{
- /* Translators: "samples" is always plural here, so no
- need for plural+singular forms.
- */
- char buf[64];
- snprintf (buf, sizeof (buf), "%u %s", sz, P_("sample", "samples", sz));
- return buf;
+ return string_compose (P_("%1 sample", "%1 samples", sz), sz);
}
string
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) ;
}
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;
XMLNode&
EngineControl::get_state ()
{
- LocaleGuard lg (X_("C"));
+ LocaleGuard lg;
XMLNode* root = new XMLNode ("AudioMIDISetup");
std::string path;
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);
{
XMLNodeList clist, cclist;
XMLNodeConstIterator citer, cciter;
- XMLNode* child;
- XMLNode* grandchild;
- XMLProperty* prop = NULL;
-
- fprintf (stderr, "EngineControl::set_state\n");
+ XMLNode const * child;
+ XMLNode const * grandchild;
+ XMLProperty const * prop = NULL;
if (root.name() != "AudioMIDISetup") {
return false;
}
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;
}
device_combo.set_active_text (state->device);
input_device_combo.set_active_text (state->input_device);
output_device_combo.set_active_text (state->output_device);
- sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
+ if (!_desired_sample_rate) {
+ sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
+ }
set_active_text_if_present (buffer_size_combo, bufsize_as_string (state->buffer_size));
set_active_text_if_present (nperiods_combo, nperiods_as_string (state->n_periods));
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;
}
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 ();
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) {
change_channels = true;
change_latency = true;
change_midi = true;
+ change_buffered_io = backend->can_use_buffered_io();
+ change_channels = true;
change_nperiods = backend->can_set_period_size() && get_popdown_string_count (nperiods_combo) > 0;
}
if (change_driver || change_device || change_channels || change_nperiods ||
(change_latency && !backend->can_change_systemic_latency_when_running ()) ||
(change_rate && !backend->can_change_sample_rate_when_running()) ||
- change_midi ||
+ change_midi || change_buffered_io ||
(change_bufsize && !backend->can_change_buffer_size_when_running())) {
restart_required = true;
} else {
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) {
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
{
if (ARDOUR::AudioEngine::instance()->running()) {
ARDOUR::AudioEngine::instance()->stop ();
} else {
+ if (!ARDOUR_UI::instance()->session_loaded) {
+ hide ();
+ }
start_engine ();
+ if (!ARDOUR_UI::instance()->session_loaded) {
+ ArdourDialog::on_response (RESPONSE_OK);
+ if (Splash::instance()) {
+ Splash::instance()->pop_front ();
+ }
+ }
}
}
}
}
+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 ()
{
EngineControl::set_desired_sample_rate (uint32_t sr)
{
_desired_sample_rate = sr;
+ if (ARDOUR::AudioEngine::instance ()->running ()
+ && ARDOUR::AudioEngine::instance ()->sample_rate () != sr) {
+ stop_engine ();
+ }
device_changed ();
}
EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
{
if (page_num == 0) {
- cancel_button->set_sensitive (true);
_measure_midi.reset();
update_sensitivity ();
- } else {
- cancel_button->set_sensitive (false);
- ok_button->set_sensitive (false);
}
if (page_num == midi_tab) {
if (ARDOUR::AudioEngine::instance()->running()) {
stop_engine ();
} else {
+ if (!ARDOUR_UI::instance()->session_loaded) {
+ hide ();
+ }
start_engine ();
+ if (!ARDOUR_UI::instance()->session_loaded) {
+ ArdourDialog::on_response (RESPONSE_OK);
+ if (Splash::instance()) {
+ Splash::instance()->pop_front ();
+ }
+ }
}
}