From 68f55d62d0b6e62cbb9800dcd5d58fc42ea39909 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 27 Oct 2023 17:11:45 +0200 Subject: [PATCH] Console1: cleanup, fix event loop initialization --- libs/surfaces/console1/c1_control.h | 2 +- libs/surfaces/console1/c1_operations.cc | 1 + libs/surfaces/console1/console1.cc | 78 +++++++++---------------- libs/surfaces/console1/console1.h | 34 +++++------ libs/surfaces/console1/wscript | 2 +- 5 files changed, 44 insertions(+), 73 deletions(-) diff --git a/libs/surfaces/console1/c1_control.h b/libs/surfaces/console1/c1_control.h index d2e211c7b3..4dca1f66c9 100644 --- a/libs/surfaces/console1/c1_control.h +++ b/libs/surfaces/console1/c1_control.h @@ -206,4 +206,4 @@ class Encoder : public Controller }; } -#endif // ardour_surface_console1_button_h \ No newline at end of file +#endif // ardour_surface_console1_button_h diff --git a/libs/surfaces/console1/c1_operations.cc b/libs/surfaces/console1/c1_operations.cc index 0163fdf70b..d95f5f0643 100644 --- a/libs/surfaces/console1/c1_operations.cc +++ b/libs/surfaces/console1/c1_operations.cc @@ -21,6 +21,7 @@ #include "ardour/phase_control.h" #include "ardour/presentation_info.h" #include "ardour/session.h" + #include "c1_control.h" #include "console1.h" diff --git a/libs/surfaces/console1/console1.cc b/libs/surfaces/console1/console1.cc index c7bab8c983..408ae956f5 100644 --- a/libs/surfaces/console1/console1.cc +++ b/libs/surfaces/console1/console1.cc @@ -16,13 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "console1.h" - -#include -#include - #include -#include #include "pbd/abstract_ui.cc" // instantiate template #include "pbd/controllable.h" @@ -41,6 +35,8 @@ #include "ardour/stripable.h" #include "ardour/track.h" #include "ardour/vca_manager.h" + +#include "console1.h" #include "c1_control.h" #include "c1_gui.h" @@ -56,6 +52,7 @@ Console1::Console1 (Session& s) , blink_state (false) , rec_enable_state (false) { + run_event_loop (); port_setup (); } @@ -63,6 +60,7 @@ Console1::~Console1 () { all_lights_out (); + stop_event_loop (); MIDISurface::drop (); tear_down_gui (); @@ -79,11 +77,6 @@ Console1::~Console1 () for (const auto& mb : multi_buttons) { delete mb.second; } - - /* stop event loop */ - DEBUG_TRACE (DEBUG::Console1, "BaseUI::quit ()\n"); - - BaseUI::quit (); } void @@ -103,24 +96,7 @@ Console1::set_active (bool yn) return 0; } - if (yn) { - - /* start event loop */ - - DEBUG_TRACE (DEBUG::Console1, "Console1::set_active\n"); - - BaseUI::run (); - - } else { - /* Control Protocol Manager never calls us with false, but - * insteads destroys us. - */ - } - ControlProtocol::set_active (yn); - /* this needs to be done that early, otherwise we'll miss the call of the signal */ - session->SessionLoaded.connect ( - session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::notify_session_loaded, this), this); DEBUG_TRACE (DEBUG::Console1, string_compose ("Console1::set_active done with yn: '%1'\n", yn)); @@ -174,14 +150,25 @@ Console1::output_port_name () const #endif } +void +Console1::run_event_loop () +{ + DEBUG_TRACE (DEBUG::Launchpad, "start event loop\n"); + BaseUI::run (); +} + +void +Console1::stop_event_loop () +{ + DEBUG_TRACE (DEBUG::Launchpad, "stop event loop\n"); + BaseUI::quit (); +} + int Console1::begin_using_device () { DEBUG_TRACE (DEBUG::Console1, "sending device inquiry message...\n"); - if (MIDISurface::begin_using_device ()) { - return -1; - } /* with this sysex command we can enter the 'native mode' But there's no need to do so @@ -191,9 +178,7 @@ Console1::begin_using_device () load_mappings (); setup_controls (); - /* - Connection to the blink-timer - */ + /* Connection to the blink-timer */ Glib::RefPtr blink_timeout = Glib::TimeoutSource::create (200); // milliseconds blink_connection = blink_timeout->connect (sigc::mem_fun (*this, &Console1::blinker)); blink_timeout->attach (main_loop ()->get_context ()); @@ -204,7 +189,12 @@ Console1::begin_using_device () periodic_timer->attach (main_loop ()->get_context ()); DEBUG_TRACE (DEBUG::Console1, "************** begin_using_device() ********************\n"); - return 0; + + create_strip_inventory (); + connect_internal_signals (); + stripable_selection_changed (); + + return MIDISurface::begin_using_device (); } void @@ -242,8 +232,6 @@ Console1::connect_session_signals () session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::master_monitor_has_changed, this), this); session->RouteAdded.connect ( session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::strip_inventory_changed, this, _1), this); - // window.signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, - // &ARDOUR_UI::tabbed_window_state_event_handler), owner)); } void @@ -265,15 +253,6 @@ Console1::connect_internal_signals () console1_connections, MISSING_INVALIDATOR, [] () { DEBUG_TRACE (DEBUG::Console1, "VerticalZoomOut\n"); }, this); } -void -Console1::notify_session_loaded () -{ - DEBUG_TRACE (DEBUG::Console1, "************** Session Loaded() ********************\n"); - create_strip_inventory (); - connect_internal_signals (); - stripable_selection_changed (); -} - void Console1::setup_controls () { @@ -436,6 +415,7 @@ Console1::stop_using_device () blink_connection.disconnect (); periodic_connection.disconnect (); stripable_connections.drop_connections (); + console1_connections.drop_connections (); MIDISurface::stop_using_device (); return 0; } @@ -505,12 +485,6 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb } } -void -Console1::tabbed_window_state_event_handler (GdkEventWindowState* ev, void* object) -{ - DEBUG_TRACE (DEBUG::Console1, string_compose ("tabbed_window_state_event_handler: %1\n", ev->type)); -} - void Console1::notify_solo_active_changed (bool state) { diff --git a/libs/surfaces/console1/console1.h b/libs/surfaces/console1/console1.h index 7a760582fd..5ca15e10fb 100644 --- a/libs/surfaces/console1/console1.h +++ b/libs/surfaces/console1/console1.h @@ -23,20 +23,14 @@ #include #include -#include - #define ABSTRACT_UI_EXPORTS -#include - -#include "glibmm/main.h" #include "pbd/abstract_ui.h" -#include "pbd/controllable.h" #include "ardour/presentation_info.h" -#include "ardour/readonly_control.h" -#include "ardour/types.h" + #include "control_protocol/control_protocol.h" -#include "gdk/gdkevents.h" +#include "control_protocol/types.h" + #include "midi_surface/midi_byte_array.h" #include "midi_surface/midi_surface.h" @@ -49,7 +43,9 @@ namespace ARDOUR { class AsyncMIDIPort; class Bundle; class Port; +class Plugin; class Processor; +class ReadOnlyControl; class Route; class Session; class MidiPort; @@ -78,9 +74,8 @@ using order_t = ARDOUR::PresentationInfo::order_t; class ControlNotFoundException : public std::exception { - public: +public: ControlNotFoundException () {} - virtual ~ControlNotFoundException () {} }; class Console1 : public MIDISurface @@ -92,9 +87,10 @@ class Console1 : public MIDISurface friend Meter; friend Encoder; - public: +public: Console1 (ARDOUR::Session&); - virtual ~Console1 (); + ~Console1 (); + void map_p (); int set_active (bool yn); @@ -275,7 +271,7 @@ class Console1 : public MIDISurface { "TRACK_COPY", ControllerID::TRACK_COPY }, { "TRACK_GROUP", ControllerID::TRACK_GROUP } }; - private: +private: std::string config_dir_name = "c1mappings"; /* GUI */ mutable C1GUI* gui; @@ -324,11 +320,12 @@ class Console1 : public MIDISurface void connect_session_signals (); void connect_internal_signals (); + void run_event_loop (); + void stop_event_loop (); + /* MIDI-Message handler - we only have controller messages */ void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb); - void tabbed_window_state_event_handler (GdkEventWindowState* ev, void* object); - void master_monitor_has_changed (); /* Strip inventory */ @@ -338,7 +335,7 @@ class Console1 : public MIDISurface void create_strip_inventory (); - void strip_inventory_changed (ARDOUR::RouteList&) { + void strip_inventory_changed (ARDOUR::RouteList&) { create_strip_inventory (); } @@ -376,7 +373,6 @@ class Console1 : public MIDISurface /* */ void all_lights_out (); - void notify_session_loaded (); void notify_transport_state_changed () override; void notify_solo_active_changed (bool) override; @@ -608,4 +604,4 @@ class Console1 : public MIDISurface PluginMappingMap pluginMappingMap; }; } -#endif /* ardour_surface_console1_h */ \ No newline at end of file +#endif /* ardour_surface_console1_h */ diff --git a/libs/surfaces/console1/wscript b/libs/surfaces/console1/wscript index 83362f7c72..455db7921c 100644 --- a/libs/surfaces/console1/wscript +++ b/libs/surfaces/console1/wscript @@ -19,7 +19,7 @@ def build(bld): ''' obj.defines = [ 'PACKAGE="ardour_console1"' ] obj.defines += [ 'ARDOURSURFACE_DLL_EXPORTS' ] - obj.includes = [ '.', './console1', './midi_surface/midi_surface'] + obj.includes = [ '.', './console1'] obj.name = 'libardour_console1' obj.target = 'ardour_console1' obj.uselib = 'GTKMM GTK GDK XML OSX'