diff --git a/gtk2_ardour/tracks_control_panel.logic.cc b/gtk2_ardour/tracks_control_panel.logic.cc index bd69f854f8..73993a4596 100644 --- a/gtk2_ardour/tracks_control_panel.logic.cc +++ b/gtk2_ardour/tracks_control_panel.logic.cc @@ -85,6 +85,7 @@ TracksControlPanel::init () EngineStateController::instance ()->EngineHalted.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::engine_stopped, this), gui_context()); /* Subscribe for udpates from EngineStateController */ + EngineStateController::instance()->PortRegistrationChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_port_registration_update, this), gui_context()); EngineStateController::instance()->BufferSizeChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_buffer_size_update, this), gui_context()); EngineStateController::instance()->DeviceListChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_device_list_update, this, _1), gui_context()); EngineStateController::instance()->InputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_input_configuration_changed, this), gui_context()); @@ -568,9 +569,6 @@ TracksControlPanel::sample_rate_changed() void TracksControlPanel::engine_running () { - populate_input_channels(); - populate_output_channels(); - _buffer_size_combo.set_active_text (bufsize_as_string (EngineStateController::instance()->get_current_buffer_size() ) ); _sample_rate_combo.set_active_text (rate_as_string (EngineStateController::instance()->get_current_sample_rate() ) ); @@ -744,6 +742,13 @@ void TracksControlPanel::on_midi_playback_active_changed(DeviceConnectionControl } +void TracksControlPanel::on_port_registration_update() +{ + populate_input_channels(); + populate_output_channels(); +} + + void TracksControlPanel::on_buffer_size_update () { diff --git a/gtk2_ardour/tracks_control_panel.logic.h b/gtk2_ardour/tracks_control_panel.logic.h index 6d9ad03c2b..fca04f9a0d 100644 --- a/gtk2_ardour/tracks_control_panel.logic.h +++ b/gtk2_ardour/tracks_control_panel.logic.h @@ -107,6 +107,7 @@ void populate_default_session_path(); // Engine State update callback handlers + void on_port_registration_update(); void on_buffer_size_update (); void on_device_list_update (bool current_device_disconnected); void on_parameter_changed (const std::string& parameter_name); diff --git a/libs/ardour/ardour/engine_state_controller.h b/libs/ardour/ardour/engine_state_controller.h index 79ac9e5481..aad51e852d 100644 --- a/libs/ardour/ardour/engine_state_controller.h +++ b/libs/ardour/ardour/engine_state_controller.h @@ -127,6 +127,9 @@ public: PBD::Signal0 InputConfigChanged; PBD::Signal0 OutputConfigChanged; + /* this signal is emitted if new ports are registered or unregistered */ + PBD::Signal0 PortRegistrationChanged; + private: EngineStateController(); // singleton @@ -210,6 +213,7 @@ private: void _on_buffer_size_change(ARDOUR::pframes_t); void _on_device_list_change(); void _on_parameter_changed (const std::string&); + void _on_ports_registration_update (); //////////////////////////////////////// //////////////////////////////////////// diff --git a/libs/ardour/engine_state_controller.cc b/libs/ardour/engine_state_controller.cc index c6bcc9d1bc..288c009070 100644 --- a/libs/ardour/engine_state_controller.cc +++ b/libs/ardour/engine_state_controller.cc @@ -57,6 +57,7 @@ EngineStateController::EngineStateController() AudioEngine::instance ()->Halted.connect_same_thread (stopped_connection, boost::bind (&EngineStateController::_on_engine_stopped, this) ); /* Subscribe for udpates from AudioEngine */ + AudioEngine::instance ()->PortRegisteredOrUnregistered.connect_same_thread (update_connections, boost::bind (&EngineStateController::_on_ports_registration_update, this) ); AudioEngine::instance()->SampleRateChanged.connect_same_thread (update_connections, boost::bind (&EngineStateController::_on_sample_rate_change, this, _1) ); AudioEngine::instance()->BufferSizeChanged.connect_same_thread (update_connections, boost::bind (&EngineStateController::_on_buffer_size_change, this, _1) ); AudioEngine::instance()->DeviceListChanged.connect_same_thread (update_connections, boost::bind (&EngineStateController::_on_device_list_change, this) ); @@ -893,10 +894,9 @@ EngineStateController::_refresh_stereo_out_channel_states() void EngineStateController::_on_engine_running () { - _update_device_channels_state(); _serialize_and_save_current_state(); - EngineRunning(); + EngineRunning(); // emit a signal } @@ -925,6 +925,15 @@ EngineStateController::_on_parameter_changed (const std::string& parameter_name) } +void +EngineStateController::_on_ports_registration_update () +{ + _update_device_channels_state(); + + PortRegistrationChanged(); // emit a signal +} + + bool EngineStateController::push_current_state_to_backend(bool start) {