From bde50d5396b49ac982686034c3165c337b7069a7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 14 Sep 2013 16:34:08 -0400 Subject: [PATCH 01/13] really fix build issues after removal of "using" directives --- libs/backends/jack/jack_connection.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/backends/jack/jack_connection.cc b/libs/backends/jack/jack_connection.cc index 00b6feb5e1..7b3d35efa5 100644 --- a/libs/backends/jack/jack_connection.cc +++ b/libs/backends/jack/jack_connection.cc @@ -16,6 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include From 31157cb343ad1b6a82134c92c77fb37d983cc5ed Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 09:57:22 -0400 Subject: [PATCH 02/13] fix ordering in session construction so that new sessions and existing ones both work --- libs/ardour/session.cc | 30 ++++++++++++++++++++++++++---- libs/ardour/session_state.cc | 7 ------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index cad869a577..e2deb71639 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -264,11 +264,18 @@ Session::Session (AudioEngine &eng, pre_engine_init (fullpath); if (_is_new) { + if (ensure_engine (sr)) { + destroy (); + throw failed_constructor (); + } + if (create (mix_template, bus_profile)) { destroy (); throw failed_constructor (); } + } else { + if (load_state (_current_snapshot_name)) { throw failed_constructor (); } @@ -284,11 +291,11 @@ Session::Session (AudioEngine &eng, sr = atoi (prop->value()); } } - } - if (ensure_engine (sr)) { - destroy (); - throw failed_constructor (); + if (ensure_engine (sr)) { + destroy (); + throw failed_constructor (); + } } if (post_engine_init ()) { @@ -361,6 +368,21 @@ Session::ensure_engine (uint32_t desired_sample_rate) return -1; } + /* the graph is just about as basic to everything else as the engine + so we create it here. this results in it coming into being at just + the right time for both new and existing sessions. + + XXX some cleanup in the new/existing path is still waiting to be + done + */ + + if (how_many_dsp_threads () > 1) { + /* For now, only create the graph if we are using >1 DSP threads, as + it is a bit slower than the old code with 1 thread. + */ + _process_graph.reset (new Graph (*this)); + } + return 0; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e847ba45ce..99fa3f4a3b 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -210,13 +210,6 @@ Session::post_engine_init () set_block_size (_engine.samples_per_cycle()); set_frame_rate (_engine.sample_rate()); - if (how_many_dsp_threads () > 1) { - /* For now, only create the graph if we are using >1 DSP threads, as - it is a bit slower than the old code with 1 thread. - */ - _process_graph.reset (new Graph (*this)); - } - n_physical_outputs = _engine.n_physical_outputs (); n_physical_inputs = _engine.n_physical_inputs (); From 7c8f3adc7522857f4b858c8480e1e580702943ec Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 10:07:27 -0400 Subject: [PATCH 03/13] allow waf to handle inconsistent case where cwiid.h is present but not the pkg-config file --- libs/surfaces/wscript | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 3a4b562629..0879cbc569 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -53,8 +53,11 @@ def configure(conf): if conf.is_defined('HAVE_CWIID_H'): conf.check_cc (header_name='bluetooth/bluetooth.h', define_name='HAVE_BLUETOOTH_H',mandatory=False) if conf.is_defined('HAVE_BLUETOOTH_H'): - autowaf.check_pkg(conf, 'cwiid', uselib_store='CWIID', atleast_version='0.6.00') - conf.define ('BUILD_WIIMOTE', 1) + autowaf.check_pkg(conf, 'cwiid', uselib_store='CWIID', atleast_version='0.6.00',mandatory=False) + if conf.is_defined ('HAVE_CWIID'): + conf.define ('BUILD_WIIMOTE', 1) + else: + print('You are have the cwiid headers needed to compile wiimote support BUT you are missing the pkg-config file for cwiid') else: print('You are missing the libbluetooth headers needed to compile wiimote support') else: From 7cc451d81d456b9073877db7c53262bc38be8c0f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 10:07:52 -0400 Subject: [PATCH 04/13] fix language issue --- libs/surfaces/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 0879cbc569..d9009bee25 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -57,7 +57,7 @@ def configure(conf): if conf.is_defined ('HAVE_CWIID'): conf.define ('BUILD_WIIMOTE', 1) else: - print('You are have the cwiid headers needed to compile wiimote support BUT you are missing the pkg-config file for cwiid') + print('You have the cwiid headers needed to compile wiimote support BUT you are missing the pkg-config file for cwiid') else: print('You are missing the libbluetooth headers needed to compile wiimote support') else: From 4d503c20539e465fb88bdba5edfb23d999c31539 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 10:18:25 -0400 Subject: [PATCH 05/13] commit some logic problems with the EngineDialog when change the driver/device name combos --- gtk2_ardour/engine_dialog.cc | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index d724f4f4d3..e8f9bfdf6b 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -387,8 +387,10 @@ EngineControl::list_devices () available_devices.push_back (i->name); } + ignore_changes++; set_popdown_strings (device_combo, available_devices); - + ignore_changes--; + if (!available_devices.empty()) { sample_rate_combo.set_sensitive (true); buffer_size_combo.set_sensitive (true); @@ -464,12 +466,20 @@ EngineControl::device_changed () } } - set_popdown_strings (sample_rate_combo, s); - if (desired.empty()) { - sample_rate_combo.set_active_text (s.front()); + if (!s.empty()) { + set_popdown_strings (sample_rate_combo, s); + + if (desired.empty()) { + sample_rate_combo.set_active_text (s.front()); + } else { + sample_rate_combo.set_active_text (desired); + } } else { - sample_rate_combo.set_active_text (desired); + /* hmm ... how to tell the user about the fact that we have no + * available sample rates. + */ } + vector bs = backend->available_buffer_sizes(device_name); s.clear (); @@ -482,9 +492,15 @@ EngineControl::device_changed () s.push_back (buf); } - set_popdown_strings (buffer_size_combo, s); - buffer_size_combo.set_active_text (s.front()); - show_buffer_duration (); + if (!s.empty()) { + set_popdown_strings (buffer_size_combo, s); + buffer_size_combo.set_active_text (s.front()); + show_buffer_duration (); + } else { + /* hmm ... how to tell the user about the fact that we have no + * available buffer sizes. + */ + } manage_control_app_sensitivity (); From 910755b51ba38ded5913270c601d7cdb1f38c884 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 10:23:37 -0400 Subject: [PATCH 06/13] fix missing initialization of two Session members, which fixes a crash during quit-without-finished-session --- libs/ardour/session.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index e2deb71639..5187679c40 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -258,6 +258,8 @@ Session::Session (AudioEngine &eng, , _suspend_timecode_transmission (0) , _speakers (new Speakers) , ignore_route_processor_changes (false) + , _midi_ports (0) + , _mmc (0) { uint32_t sr = 0; @@ -496,9 +498,9 @@ Session::destroy () /* not strictly necessary, but doing it here allows the shared_ptr debugging to work */ playlists.reset (); - delete _mmc; - delete _midi_ports; - delete _locations; + delete _mmc; _mmc = 0; + delete _midi_ports; _midi_ports = 0; + delete _locations; _locations = 0; DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n"); From ed61a9ebbde06f5bf2e8e09caea496cc1eca2022 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 11:10:05 -0400 Subject: [PATCH 07/13] update buffer size duration (msecs) while displaying saved audio/MIDI setup state --- gtk2_ardour/engine_dialog.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index e8f9bfdf6b..a47c6e0a0c 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -647,6 +647,10 @@ EngineControl::maybe_display_saved_state () sample_rate_combo.set_active_text (state->sample_rate); } buffer_size_combo.set_active_text (state->buffer_size); + /* call this explicitly because we're ignoring changes to + the controls at this point. + */ + show_buffer_duration (); input_latency.set_value (state->input_latency); output_latency.set_value (state->output_latency); ignore_changes--; From 39ee88b3f9e73421690230cfd7e11aee9be8b7ec Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 12:08:19 -0400 Subject: [PATCH 08/13] more session construction order changes, and removal of n_physical_{inputs,outputs} members which were (a) not initialized early enough (b) not used anywhere except monitor bus connection. Things almost make sense now. --- libs/ardour/ardour/session.h | 11 +--- libs/ardour/session.cc | 122 +++++++++++------------------------ libs/ardour/session_state.cc | 46 +++++++++++-- 3 files changed, 81 insertions(+), 98 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 1d81473f1d..7337e2d1ea 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1071,7 +1071,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi boost::scoped_ptr _session_dir; void hookup_io (); - int when_engine_running (); void graph_reordered (); /** current snapshot name, without the .ardour suffix */ @@ -1137,8 +1136,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void auto_loop_changed (Location *); void auto_loop_declick_range (Location *, framepos_t &, framepos_t &); + int ensure_engine (uint32_t desired_sample_rate); void pre_engine_init (std::string path); int post_engine_init (); + int immediately_post_engine (); void remove_empty_sounds (); void setup_midi_control (); @@ -1521,13 +1522,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi float opt ); - /* number of hardware ports we're using, - based on max (requested,available) - */ - - ChanCount n_physical_outputs; - ChanCount n_physical_inputs; - int find_all_sources (std::string path, std::set& result); int find_all_sources_across_snapshots (std::set& result, bool exclude_this_snapshot); @@ -1624,7 +1618,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void setup_ltc (); void setup_click (); void setup_bundles (); - int ensure_engine (uint32_t desired_sample_rate); }; } // namespace ARDOUR diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5187679c40..746732f76e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -370,14 +370,18 @@ Session::ensure_engine (uint32_t desired_sample_rate) return -1; } - /* the graph is just about as basic to everything else as the engine - so we create it here. this results in it coming into being at just - the right time for both new and existing sessions. + return immediately_post_engine (); - XXX some cleanup in the new/existing path is still waiting to be - done - */ +} +int +Session::immediately_post_engine () +{ + /* Do various initializations that should take place directly after we + * know that the engine is running, but before we either create a + * session or set state for an existing one. + */ + if (how_many_dsp_threads () > 1) { /* For now, only create the graph if we are using >1 DSP threads, as it is a bit slower than the old code with 1 thread. @@ -385,6 +389,31 @@ Session::ensure_engine (uint32_t desired_sample_rate) _process_graph.reset (new Graph (*this)); } + /* every time we reconnect, recompute worst case output latencies */ + + _engine.Running.connect_same_thread (*this, boost::bind (&Session::initialize_latencies, this)); + + if (synced_to_jack()) { + _engine.transport_stop (); + } + + if (config.get_jack_time_master()) { + _engine.transport_locate (_transport_frame); + } + + try { + BootMessage (_("Set up LTC")); + setup_ltc (); + BootMessage (_("Set up Click")); + setup_click (); + BootMessage (_("Set up standard connections")); + setup_bundles (); + } + + catch (failed_constructor& err) { + return -1; + } + return 0; } @@ -707,81 +736,6 @@ Session::setup_bundles () } -int -Session::when_engine_running () -{ - /* every time we reconnect, recompute worst case output latencies */ - - _engine.Running.connect_same_thread (*this, boost::bind (&Session::initialize_latencies, this)); - - if (synced_to_jack()) { - _engine.transport_stop (); - } - - if (config.get_jack_time_master()) { - _engine.transport_locate (_transport_frame); - } - - - try { - BootMessage (_("Set up LTC")); - setup_ltc (); - BootMessage (_("Set up Click")); - setup_click (); - BootMessage (_("Set up standard connections")); - setup_bundles (); - } - - catch (failed_constructor& err) { - return -1; - } - - BootMessage (_("Setup signal flow and plugins")); - - /* Reset all panners */ - - Delivery::reset_panners (); - - /* this will cause the CPM to instantiate any protocols that are in use - * (or mandatory), which will pass it this Session, and then call - * set_state() on each instantiated protocol to match stored state. - */ - - ControlProtocolManager::instance().set_session (this); - - /* This must be done after the ControlProtocolManager set_session above, - as it will set states for ports which the ControlProtocolManager creates. - */ - - // XXX set state of MIDI::Port's - // MidiPortManager::instance()->set_port_states (Config->midi_port_states ()); - - /* And this must be done after the MIDI::Manager::set_port_states as - * it will try to make connections whose details are loaded by set_port_states. - */ - - hookup_io (); - - /* Let control protocols know that we are now all connected, so they - * could start talking to surfaces if they want to. - */ - - ControlProtocolManager::instance().midi_connectivity_established (); - - if (_is_new && !no_auto_connect()) { - Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock()); - auto_connect_master_bus (); - } - - _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty)); - - /* update latencies */ - - initialize_latencies (); - - return 0; -} - void Session::auto_connect_master_bus () { @@ -941,14 +895,14 @@ Session::add_monitor_section () /* Monitor bus is audio only */ - uint32_t mod = n_physical_outputs.get (DataType::AUDIO); - uint32_t limit = _monitor_out->n_outputs().get (DataType::AUDIO); vector outputs[DataType::num_types]; for (uint32_t i = 0; i < DataType::num_types; ++i) { _engine.get_physical_outputs (DataType (DataType::Symbol (i)), outputs[i]); } - + + uint32_t mod = outputs[DataType::AUDIO].size(); + uint32_t limit = _monitor_out->n_outputs().get (DataType::AUDIO); if (mod != 0) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 99fa3f4a3b..c33fd91b5d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -210,9 +210,6 @@ Session::post_engine_init () set_block_size (_engine.samples_per_cycle()); set_frame_rate (_engine.sample_rate()); - n_physical_outputs = _engine.n_physical_outputs (); - n_physical_inputs = _engine.n_physical_inputs (); - BootMessage (_("Using configuration")); _midi_ports = new MidiPortManager; @@ -273,8 +270,47 @@ Session::post_engine_init () Config->map_parameters (ff); config.map_parameters (ft); - when_engine_running (); - + /* Reset all panners */ + + Delivery::reset_panners (); + + /* this will cause the CPM to instantiate any protocols that are in use + * (or mandatory), which will pass it this Session, and then call + * set_state() on each instantiated protocol to match stored state. + */ + + ControlProtocolManager::instance().set_session (this); + + /* This must be done after the ControlProtocolManager set_session above, + as it will set states for ports which the ControlProtocolManager creates. + */ + + // XXX set state of MIDI::Port's + // MidiPortManager::instance()->set_port_states (Config->midi_port_states ()); + + /* And this must be done after the MIDI::Manager::set_port_states as + * it will try to make connections whose details are loaded by set_port_states. + */ + + hookup_io (); + + /* Let control protocols know that we are now all connected, so they + * could start talking to surfaces if they want to. + */ + + ControlProtocolManager::instance().midi_connectivity_established (); + + if (_is_new && !no_auto_connect()) { + Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock()); + auto_connect_master_bus (); + } + + _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty)); + + /* update latencies */ + + initialize_latencies (); + _locations->changed.connect_same_thread (*this, boost::bind (&Session::locations_changed, this)); _locations->added.connect_same_thread (*this, boost::bind (&Session::locations_added, this, _1)); From 2a3dfb5e82880bacc6ddcfdb270902010a32d931 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 15:21:32 -0400 Subject: [PATCH 09/13] various bits of polish for the latency tab of audio/midi setup dialog --- gtk2_ardour/engine_dialog.cc | 96 +++++++++++++++++++++++++++--------- gtk2_ardour/engine_dialog.h | 7 ++- 2 files changed, 78 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index a47c6e0a0c..188824d3cc 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -31,6 +31,7 @@ #include "pbd/xml++.h" #include "pbd/unwind.h" +#include #include #include #include @@ -67,9 +68,10 @@ EngineControl::EngineControl () , ports_adjustment (128, 8, 1024, 1, 16) , ports_spinner (ports_adjustment) , control_app_button (_("Launch Control App")) - , lm_measure_button (_("Measure latency")) + , lm_start_stop_label (_("Measure latency")) , lm_use_button (_("Use results")) , lm_table (5, 2) + , have_lm_results (false) , basic_packer (9, 3) , ignore_changes (0) , _desired_sample_rate (0) @@ -82,9 +84,9 @@ EngineControl::EngineControl () control_app_button.signal_clicked().connect (mem_fun (*this, &EngineControl::control_app_button_clicked)); manage_control_app_sensitivity (); - add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK); - add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY); + cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + ok_button = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK); + apply_button = add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY); /* Pick up any existing audio setup configuration, if appropriate */ @@ -217,42 +219,75 @@ EngineControl::build_notebook () lm_table.attach (lm_title, 0, 2, row, row+1, xopt, (AttachOptions) 0); row++; - lm_preamble.set_width_chars (60); - lm_preamble.set_line_wrap (true); - lm_preamble.set_markup (_("1. Turn down the volume on your hardware to a very low level.\n\n\ -2. Connect the two channels that you select below using either a cable or (less ideally) a speaker \ -and microphone.\n\n\ -3. Once the channels are connected, click the \"Measure latency\" button.\n\n\ -4. When satisfied with the results, click the \"Use results\" button.")); + Gtk::Label* preamble; - lm_table.attach (lm_preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); + preamble = manage (new Label); + preamble->set_width_chars (60); + preamble->set_line_wrap (true); + preamble->set_markup (_("Turn down the volume on your hardware to a very low level.")); + + lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); + row++; + + preamble = manage (new Label); + preamble->set_width_chars (60); + preamble->set_line_wrap (true); + preamble->set_markup (_("Select two channels below and connect them using a cable or (less ideally) a speaker and microphone.")); + + lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); row++; label = manage (new Label (_("Output channel"))); lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); - lm_table.attach (lm_output_channel_combo, 1, 2, row, row+1, xopt, (AttachOptions) 0); + + Gtk::Alignment* misc_align = manage (new Alignment (0.0, 0.5)); + misc_align->add (lm_output_channel_combo); + lm_table.attach (*misc_align, 1, 2, row, row+1, xopt, (AttachOptions) 0); ++row; label = manage (new Label (_("Input channel"))); lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); - lm_table.attach (lm_input_channel_combo, 1, 2, row, row+1, xopt, (AttachOptions) 0); + + misc_align = manage (new Alignment (0.0, 0.5)); + misc_align->add (lm_input_channel_combo); + lm_table.attach (*misc_align, 1, 2, row, row+1, FILL, (AttachOptions) 0); ++row; xopt = AttachOptions(0); + lm_measure_button.add (lm_start_stop_label); + lm_measure_button.signal_toggled().connect (sigc::mem_fun (*this, &EngineControl::latency_button_toggled)); lm_use_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::use_latency_button_clicked)); lm_use_button.set_sensitive (false); + + preamble = manage (new Label); + preamble->set_width_chars (60); + preamble->set_line_wrap (true); + preamble->set_markup (_("Once the channels are connected, click the \"Measure latency\" button.")); + lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); + row++; + lm_table.attach (lm_measure_button, 0, 2, row, row+1, xopt, (AttachOptions) 0); ++row; lm_table.attach (lm_results, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); ++row; + + + preamble = manage (new Label); + preamble->set_width_chars (60); + preamble->set_line_wrap (true); + preamble->set_markup (_("When satisfied with the results, click the \"Use results\" button.")); + lm_table.attach (*preamble, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0); + row++; + lm_table.attach (lm_use_button, 0, 2, row, row+1, xopt, (AttachOptions) 0); ++row; lm_results.set_markup ("No measurement results yet"); + lm_vbox.set_border_width (12); lm_vbox.pack_start (lm_table, false, false); /* pack it all up */ @@ -316,7 +351,6 @@ EngineControl::enable_latency_tab () lm_input_channel_combo.set_active_text (inputs.front()); lm_measure_button.set_sensitive (true); - lm_use_button.set_sensitive (true); } void @@ -1018,9 +1052,19 @@ EngineControl::on_switch_page (GtkNotebookPage*, guint page_num) if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) { disable_latency_tab (); } + enable_latency_tab (); + + cancel_button->set_sensitive (false); + ok_button->set_sensitive (false); + apply_button->set_sensitive (false); + } else { ARDOUR::AudioEngine::instance()->stop_latency_detection(); + + cancel_button->set_sensitive (true); + ok_button->set_sensitive (true); + apply_button->set_sensitive (true); } } @@ -1030,15 +1074,9 @@ bool EngineControl::check_latency_measurement () { MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm (); - static uint32_t cnt = 0; if (mtdm->resolve () < 0) { - string txt = _("No signal detected "); - uint32_t dots = cnt++%10; - for (uint32_t i = 0; i < dots; ++i) { - txt += '.'; - } - lm_results.set_text (txt); + lm_results.set_markup (string_compose ("%1", _("No signal detected "))); return true; } @@ -1078,6 +1116,7 @@ EngineControl::check_latency_measurement () lm_measure_button.set_active (false); lm_use_button.set_sensitive (true); strcat (buf, " (set)"); + have_lm_results = true; } lm_results.set_text (buf); @@ -1095,10 +1134,19 @@ EngineControl::latency_button_toggled () ARDOUR::AudioEngine::instance()->start_latency_detection (); lm_results.set_text (_("Detecting ...")); latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250); - - } else { + lm_start_stop_label.set_text (_("Cancel measurement")); + have_lm_results = false; + lm_input_channel_combo.set_sensitive (false); + lm_output_channel_combo.set_sensitive (false); + } else { ARDOUR::AudioEngine::instance()->stop_latency_detection (); latency_timeout.disconnect (); + lm_start_stop_label.set_text (_("Measure latency")); + if (!have_lm_results) { + lm_results.set_markup ("No measurement results yet"); + } + lm_input_channel_combo.set_sensitive (true); + lm_output_channel_combo.set_sensitive (true); } } diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 98ddf2c1b3..52214c9bd6 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -75,13 +75,18 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { Gtk::ComboBoxText lm_output_channel_combo; Gtk::ComboBoxText lm_input_channel_combo; + Gtk::Label lm_start_stop_label; Gtk::ToggleButton lm_measure_button; Gtk::Button lm_use_button; Gtk::Label lm_title; - Gtk::Label lm_preamble; Gtk::Label lm_results; Gtk::Table lm_table; Gtk::VBox lm_vbox; + bool have_lm_results; + + Gtk::Button* cancel_button; + Gtk::Button* ok_button; + Gtk::Button* apply_button; /* JACK specific */ From cb31e34a5ca89bad4b73499de7caa6c31f79423f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 18:47:30 -0400 Subject: [PATCH 10/13] end latency detection if AMS window closed while running detection (plus some non-functioning changes to try to get spinbutton text entry to work --- gtk2_ardour/engine_dialog.cc | 71 ++++++++++++++++++++++++++---------- gtk2_ardour/engine_dialog.h | 3 ++ 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 188824d3cc..c22bc5e12e 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -67,7 +67,7 @@ EngineControl::EngineControl () , output_channels (output_channels_adjustment) , ports_adjustment (128, 8, 1024, 1, 16) , ports_spinner (ports_adjustment) - , control_app_button (_("Launch Control App")) + , control_app_button (_("Device Control Panel")) , lm_start_stop_label (_("Measure latency")) , lm_use_button (_("Use results")) , lm_table (5, 2) @@ -113,6 +113,13 @@ EngineControl::on_response (int response_id) push_state_to_backend (true); hide (); break; + case RESPONSE_DELETE_EVENT: { + GdkEventButton ev; + ev.type = GDK_BUTTON_PRESS; + ev.button = 1; + on_delete_event ((GdkEventAny*) &ev); + break; + } default: hide (); } @@ -171,17 +178,22 @@ EngineControl::build_notebook () row++; + input_channels.set_editable (true); + label = manage (left_aligned_label (_("Input Channels:"))); basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); basic_packer.attach (input_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0); ++row; + output_channels.set_editable (true); label = manage (left_aligned_label (_("Output Channels:"))); basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); basic_packer.attach (output_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0); ++row; + input_latency.set_numeric (true); + input_latency.set_editable (true); label = manage (left_aligned_label (_("Hardware input latency:"))); basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); @@ -1124,29 +1136,40 @@ EngineControl::check_latency_measurement () return true; } +void +EngineControl::start_latency_detection () +{ + ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text()); + ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text()); + ARDOUR::AudioEngine::instance()->start_latency_detection (); + lm_results.set_text (_("Detecting ...")); + latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250); + lm_start_stop_label.set_text (_("Cancel measurement")); + have_lm_results = false; + lm_input_channel_combo.set_sensitive (false); + lm_output_channel_combo.set_sensitive (false); +} + +void +EngineControl::end_latency_detection () +{ + ARDOUR::AudioEngine::instance()->stop_latency_detection (); + latency_timeout.disconnect (); + lm_start_stop_label.set_text (_("Measure latency")); + if (!have_lm_results) { + lm_results.set_markup ("No measurement results yet"); + } + lm_input_channel_combo.set_sensitive (true); + lm_output_channel_combo.set_sensitive (true); +} + void EngineControl::latency_button_toggled () { if (lm_measure_button.get_active ()) { - - ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text()); - ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text()); - ARDOUR::AudioEngine::instance()->start_latency_detection (); - lm_results.set_text (_("Detecting ...")); - latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250); - lm_start_stop_label.set_text (_("Cancel measurement")); - have_lm_results = false; - lm_input_channel_combo.set_sensitive (false); - lm_output_channel_combo.set_sensitive (false); + start_latency_detection (); } else { - ARDOUR::AudioEngine::instance()->stop_latency_detection (); - latency_timeout.disconnect (); - lm_start_stop_label.set_text (_("Measure latency")); - if (!have_lm_results) { - lm_results.set_markup ("No measurement results yet"); - } - lm_input_channel_combo.set_sensitive (true); - lm_output_channel_combo.set_sensitive (true); + end_latency_detection (); } } @@ -1166,3 +1189,13 @@ EngineControl::use_latency_button_clicked () input_latency_adjustment.set_value (one_way); output_latency_adjustment.set_value (one_way); } + +bool +EngineControl::on_delete_event (GdkEventAny* ev) +{ + if (notebook.get_current_page() == 2) { + /* currently on latency tab - be sure to clean up */ + end_latency_detection (); + } + return ArdourDialog::on_delete_event (ev); +} diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 52214c9bd6..14724c8bfe 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -181,8 +181,11 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { sigc::connection latency_timeout; void enable_latency_tab (); void disable_latency_tab (); + void start_latency_detection (); + void end_latency_detection (); void on_switch_page (GtkNotebookPage*, guint page_num); + bool on_delete_event (GdkEventAny*); }; #endif /* __gtk2_ardour_engine_dialog_h__ */ From 710ee36eaa5cb55d02322373e9bbccda8095979a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 22:02:36 -0400 Subject: [PATCH 11/13] a few DEBUG_TRACE improvements --- libs/gtkmm2ext/keyboard.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 5087f61a23..2bfb5fa58b 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -233,8 +233,9 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event) DEBUG_TRACE ( DEBUG::Keyboard, string_compose ( - "Snoop widget %1 key %2 type %3 state %4 magic %5\n", - widget, event->keyval, event->type, event->state, _some_magic_widget_has_focus + "Snoop widget %1 name: [%6] key %2 type %3 state %4 magic %5\n", + widget, event->keyval, event->type, event->state, _some_magic_widget_has_focus, + gtk_widget_get_name (widget) ) ); @@ -324,6 +325,8 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event) } } + DEBUG_TRACE (DEBUG::Keyboard, string_compose ("snooper returns %1\n", ret)); + return ret; } @@ -346,6 +349,7 @@ bool Keyboard::enter_window (GdkEventCrossing *, Gtk::Window* win) { current_window = win; + DEBUG_TRACE (DEBUG::Keyboard, string_compose ("Entering window, title = %1\n", win->get_title())); return false; } From 61b98d3e9f6585ef51caf79bb1668c4c6bcd141c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 22:03:27 -0400 Subject: [PATCH 12/13] check for an existing PublicEditor instance AFTER attempting to handle a key press in a window that has called relay_key_press(), so that normal key handling works there (e.g. audio/MIDI setup) --- gtk2_ardour/utils.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 1b87a3d444..304b8508c6 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -365,12 +365,11 @@ relay_key_press (GdkEventKey* ev, Gtk::Window* win) { PublicEditor& ed (PublicEditor::instance()); - if (&ed == 0) { - /* early key press in pre-main-window-dialogs, no editor yet */ - return false; - } - if (!key_press_focus_accelerator_handler (*win, ev)) { + if (&ed == 0) { + /* early key press in pre-main-window-dialogs, no editor yet */ + return false; + } return ed.on_key_press_event(ev); } else { return true; From c8b32e2f8bed225b8f5ceac130eea6632f595492 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2013 22:03:59 -0400 Subject: [PATCH 13/13] minor fixups for audio/MIDI setup spin buttons (now editable, as they should be) --- gtk2_ardour/ardour_ui.cc | 4 +--- gtk2_ardour/engine_dialog.cc | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 3543405cf0..547eaf4e39 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -4154,9 +4154,7 @@ ARDOUR_UI::do_audio_midi_setup (uint32_t desired_sample_rate) _audio_midi_setup->set_desired_sample_rate (desired_sample_rate); - int r = _audio_midi_setup->run (); - - switch (r) { + switch (_audio_midi_setup->run()) { case Gtk::RESPONSE_OK: return 0; case Gtk::RESPONSE_APPLY: diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index c22bc5e12e..5fff838a6f 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -76,6 +76,8 @@ EngineControl::EngineControl () , ignore_changes (0) , _desired_sample_rate (0) { + set_name (X_("AudioMIDISetup")); + build_notebook (); get_vbox()->set_border_width (12); @@ -177,14 +179,21 @@ EngineControl::build_notebook () basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, xopt, (AttachOptions) 0); row++; - - input_channels.set_editable (true); + input_channels.set_name ("InputChannels"); + input_channels.set_flags(Gtk::CAN_FOCUS); + input_channels.set_digits(0); + input_channels.set_wrap(false); + output_channels.set_editable (true); label = manage (left_aligned_label (_("Input Channels:"))); basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); basic_packer.attach (input_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0); ++row; + output_channels.set_name ("OutputChannels"); + output_channels.set_flags(Gtk::CAN_FOCUS); + output_channels.set_digits(0); + output_channels.set_wrap(false); output_channels.set_editable (true); label = manage (left_aligned_label (_("Output Channels:"))); @@ -192,7 +201,10 @@ EngineControl::build_notebook () basic_packer.attach (output_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0); ++row; - input_latency.set_numeric (true); + input_latency.set_name ("InputLatency"); + input_latency.set_flags(Gtk::CAN_FOCUS); + input_latency.set_digits(0); + input_latency.set_wrap(false); input_latency.set_editable (true); label = manage (left_aligned_label (_("Hardware input latency:"))); @@ -202,6 +214,12 @@ EngineControl::build_notebook () basic_packer.attach (*label, 2, 3, row, row+1, xopt, (AttachOptions) 0); ++row; + output_latency.set_name ("OutputLatency"); + output_latency.set_flags(Gtk::CAN_FOCUS); + output_latency.set_digits(0); + output_latency.set_wrap(false); + output_latency.set_editable (true); + label = manage (left_aligned_label (_("Hardware output latency:"))); basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0); basic_packer.attach (output_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0); @@ -327,7 +345,6 @@ EngineControl::build_notebook () input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); - input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels)); output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels)); @@ -1199,3 +1216,4 @@ EngineControl::on_delete_event (GdkEventAny* ev) } return ArdourDialog::on_delete_event (ev); } +