From 53e24168b673ce078096d6f3463fa6e08dc382fd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 26 Oct 2023 21:16:12 +0200 Subject: [PATCH] Partially revert "Clean init process to prevent exceptions" This reverts commit 94fec7fd8ab59b41c2d22cd819fac520c2416cf8 except whitespace and intent changes as per discussion on https://github.com/Ardour/ardour/pull/834 --- libs/surfaces/console1/console1.cc | 60 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/libs/surfaces/console1/console1.cc b/libs/surfaces/console1/console1.cc index ea06e0bc2b..3743d41b5d 100644 --- a/libs/surfaces/console1/console1.cc +++ b/libs/surfaces/console1/console1.cc @@ -179,15 +179,15 @@ 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 f0 7d 20 00 00 00 01 00 7f 49 6f 6c 73 00 f7 */ - if (_in_use) - return 0; - load_mappings (); setup_controls (); @@ -202,30 +202,11 @@ Console1::begin_using_device () Glib::RefPtr periodic_timer = Glib::TimeoutSource::create (100); periodic_connection = periodic_timer->connect (sigc::mem_fun (*this, &Console1::periodic)); periodic_timer->attach (main_loop ()->get_context ()); - connect_session_signals (); - connect_internal_signals (); - create_strip_inventory (); - _in_use = true; DEBUG_TRACE (DEBUG::Console1, "************** begin_using_device() ********************\n"); return 0; } -int -Console1::stop_using_device () -{ - DEBUG_TRACE (DEBUG::Console1, "stop_using_device()\n"); - if (!_in_use) - return 0; - blink_connection.disconnect (); - periodic_connection.disconnect (); - stripable_connections.drop_connections (); - session_connections.drop_connections (); - console1_connections.drop_connections (); - _in_use = false; - return 0; -} - void Console1::connect_session_signals () { @@ -288,6 +269,8 @@ void Console1::notify_session_loaded () { DEBUG_TRACE (DEBUG::Console1, "************** Session Loaded() ********************\n"); + create_strip_inventory (); + connect_internal_signals (); stripable_selection_changed (); } @@ -445,6 +428,17 @@ Console1::setup_controls () new Meter (this, ControllerID::OUTPUT_METER_R, boost::function ([] () {})); } +int +Console1::stop_using_device () +{ + DEBUG_TRACE (DEBUG::Console1, "stop_using_device()\n"); + + blink_connection.disconnect (); + periodic_connection.disconnect (); + stripable_connections.drop_connections (); + return 0; +} + void Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb) { @@ -543,12 +537,11 @@ Console1::notify_transport_state_changed () void Console1::stripable_selection_changed () { - if (!_in_use) - return; DEBUG_TRACE (DEBUG::Console1, "stripable_selection_changed \n"); std::shared_ptr r = ControlProtocol::first_selected_stripable (); - if (r) + if (r) { set_current_stripable (r); + } } void @@ -1205,21 +1198,24 @@ Console1::select_rid_by_index (uint32_t index) #ifdef MIXBUS rid = index + offset; #else - if (index == master_index) + if (index == master_index) { rid = 1; - else + } else { rid = index + 1 + offset; + } #endif DEBUG_TRACE (DEBUG::Console1, string_compose ("rid %1\n", rid)); - if (rid > (max_strip_index + 1 + offset)) - success = false; + if (rid > ( max_strip_index + 1 + offset )) { + success = false; + } std::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); if (s) { session->selection ().select_stripable_and_maybe_group (s, true, false, 0); - } else { - success = false; } - if (!success) { + else { + success = false; + } + if( !success ){ map_select (); } }