#include "pbd/convert.h"
#include "pbd/error.h"
+#include "opts.h"
#include "ardour_ui.h"
#include "engine_dialog.h"
#include "gui_thread.h"
, ignore_changes (0)
, _desired_sample_rate (0)
, started_at_least_once (false)
+ , queue_device_changed (false)
{
using namespace Notebook_Helpers;
vector<string> backend_names;
}
if (backend_combo.get_active_text().empty()) {
+ PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
backend_combo.set_active_text (backend_names.front());
}
- {
- /* ignore: don't save state */
- PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
- backend_changed ();
- }
+ backend_changed ();
/* in case the setting the backend failed, e.g. stale config, from set_state(), try again */
if (0 == ARDOUR::AudioEngine::instance()->current_backend()) {
EngineControl::on_show ()
{
ArdourDialog::on_show ();
+ 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();
}
push_state_to_backend (true);
break;
case RESPONSE_OK:
+#ifdef PLATFORM_WINDOWS
+ // For some reason we don't understand, 'hide()'
+ // needs to get called first in Windows
+ hide ();
+
+ // 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();
+ }
+ }
+ }
+ push_state_to_backend (true);
+ break;
+#else
push_state_to_backend (true);
hide ();
break;
+#endif
case RESPONSE_DELETE_EVENT:
{
GdkEventButton ev;
basic_packer.attach (lm_button_audio, 3, 4, row-1, row+1, xopt, xopt);
++row;
- label = manage (left_aligned_label (_("MIDI System")));
+ label = manage (left_aligned_label (_("MIDI System:")));
basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
basic_packer.attach (midi_option_combo, 1, 2, row, row + 1, SHRINK, (AttachOptions) 0);
basic_packer.attach (midi_devices_button, 3, 4, row, row+1, xopt, xopt);
EngineControl::print_channel_count (Gtk::SpinButton* sb)
{
if (ARDOUR::Profile->get_mixbus()) {
- cout << "Mixbus crash trap. sb->get_value(): " << sb->get_value();
return true;
}
assert (backend);
string device_name = device_combo.get_active_text ();
vector<string> s;
+
+ if (device_name != backend->device_name()) {
+ /* we set the backend-device to query various device related intormation.
+ * This has the side effect that backend->device_name() will match
+ * the device_name and 'change_device' will never be true.
+ * so work around this by setting...
+ */
+ queue_device_changed = true;
+ }
//the device name must be set FIRST so ASIO can populate buffersizes and the control panel button
backend->set_device_name(device_name);
if (0 == period) {
period = backend->default_buffer_size(device_name);
}
- buffer_size_combo.set_active_text (bufsize_as_string (period));
+ set_active_text_if_present (buffer_size_combo, bufsize_as_string (period));
show_buffer_duration ();
} else {
buffer_size_combo.set_sensitive (false);
/* Translators: "samples" is always plural here, so no
need for plural+singular forms.
*/
- char buf[32];
- snprintf (buf, sizeof (buf), _("%u samples"), sz);
+ char buf[64];
+ snprintf (buf, sizeof (buf), "%u %s", sz, P_("sample", "samples", sz));
return buf;
}
*/
show_buffer_duration ();
- if (!ignore_changes) {
- save_state ();
- }
}
EngineControl::buffer_size_changed ()
{
show_buffer_duration ();
- if (!ignore_changes) {
- save_state ();
- }
}
void
} else {
midi_devices_button.set_sensitive (true);
}
-
- if (!ignore_changes) {
- save_state ();
- }
}
void
EngineControl::parameter_changed ()
{
- if (!ignore_changes) {
- save_state ();
- }
}
EngineControl::State
if (!_desired_sample_rate) {
sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
}
- buffer_size_combo.set_active_text (bufsize_as_string (state->buffer_size));
+ set_active_text_if_present (buffer_size_combo, bufsize_as_string (state->buffer_size));
/* call this explicitly because we're ignoring changes to
the controls at this point.
*/
for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
if ((*i)->active) {
- ignore_changes++;
+ PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
backend_combo.set_active_text ((*i)->backend);
driver_combo.set_active_text ((*i)->driver);
device_combo.set_active_text ((*i)->device);
sample_rate_combo.set_active_text (rate_as_string ((*i)->sample_rate));
- buffer_size_combo.set_active_text (bufsize_as_string ((*i)->buffer_size));
+ set_active_text_if_present (buffer_size_combo, bufsize_as_string ((*i)->buffer_size));
input_latency.set_value ((*i)->input_latency);
output_latency.set_value ((*i)->output_latency);
midi_option_combo.set_active_text ((*i)->midi_option);
- ignore_changes--;
break;
}
}
}
}
- if (get_device_name() != backend->device_name()) {
+ if (queue_device_changed || get_device_name() != backend->device_name()) {
change_device = true;
}
}
}
+ queue_device_changed = false;
+
if (!_have_control) {
/* We do not have control over the backend, so the best we can
if (!state) {
state = save_state ();
assert (state);
+ } else {
+ store_state(state);
}
/* all off */
uint32_t samples;
if (sscanf (txt.c_str(), "%d", &samples) != 1) {
+ fprintf(stderr, "Find a trout and repeatedly slap the nearest C++ who throws exceptions without catching them.\n");
+ fprintf(stderr, "Ardour will likely crash now, giving you time to get the trout.\n");
throw exception ();
}
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
assert (backend);
- buffer_size_combo.set_active_text (bufsize_as_string (backend->buffer_size()));
+ set_active_text_if_present (buffer_size_combo, bufsize_as_string (backend->buffer_size()));
sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
buffer_size_combo.set_sensitive (true);
void
EngineControl::device_list_changed ()
{
- PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
+ PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1); // ??
list_devices ();
midi_option_changed();
}