From 3e101dd895bb167a9d750444dfa9c5a7afe0c8e7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Jun 2021 22:20:59 -0400 Subject: [PATCH] Add BasicUI::locations() Towards removing the direct use of Session by surfaces. --- libs/surfaces/contourdesign/contourdesign.cc | 4 ++-- libs/surfaces/control_protocol/basic_ui.cc | 12 ++++++++++++ .../control_protocol/control_protocol/basic_ui.h | 8 +++++++- libs/surfaces/faderport8/actions.cc | 4 ++-- libs/surfaces/faderport8/callbacks.cc | 2 +- libs/surfaces/mackie/mcp_buttons.cc | 4 ++-- libs/surfaces/maschine2/callbacks.cc | 2 +- libs/surfaces/osc/osc.cc | 4 ++-- libs/surfaces/osc/osc_global_observer.cc | 2 +- libs/surfaces/tranzport/general.cc | 4 ++-- libs/surfaces/us2400/mcp_buttons.cc | 4 ++-- 11 files changed, 34 insertions(+), 16 deletions(-) diff --git a/libs/surfaces/contourdesign/contourdesign.cc b/libs/surfaces/contourdesign/contourdesign.cc index 9e89330db1..9835721254 100644 --- a/libs/surfaces/contourdesign/contourdesign.cc +++ b/libs/surfaces/contourdesign/contourdesign.cc @@ -559,7 +559,7 @@ ContourDesignControlProtocol::handle_button_release (unsigned short btn) void ContourDesignControlProtocol::prev_marker_keep_rolling () { - timepos_t pos = _session->locations()->first_mark_before (timepos_t (transport_sample())); + timepos_t pos = locations()->first_mark_before (timepos_t (transport_sample())); if (pos.positive() || pos.zero()) { locate (pos.samples()); @@ -571,7 +571,7 @@ ContourDesignControlProtocol::prev_marker_keep_rolling () void ContourDesignControlProtocol::next_marker_keep_rolling () { - timepos_t pos = _session->locations()->first_mark_after (timepos_t (transport_sample())); + timepos_t pos = locations()->first_mark_after (timepos_t (transport_sample())); if (pos.positive() || pos.zero()) { locate (pos.samples()); diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 111916d1c0..a4c835bd51 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -852,3 +852,15 @@ BasicUI::master_out () const { return _session->master_out (); } + +const Locations* +BasicUI::locations () const +{ + return _session->locations (); +} + +Locations* +BasicUI::locations () +{ + return _session->locations (); +} diff --git a/libs/surfaces/control_protocol/control_protocol/basic_ui.h b/libs/surfaces/control_protocol/control_protocol/basic_ui.h index 32d320d392..2c8f6565e3 100644 --- a/libs/surfaces/control_protocol/control_protocol/basic_ui.h +++ b/libs/surfaces/control_protocol/control_protocol/basic_ui.h @@ -38,6 +38,7 @@ namespace ARDOUR { +class Locations; class Session; class SessionConfiguration; class Stripable; @@ -181,7 +182,12 @@ class LIBCONTROLCP_API BasicUI { boost::shared_ptr monitor_out () const; boost::shared_ptr master_out () const; - protected: + /* Locations */ + + const Locations* locations () const; + Locations* locations (); + +protected: Session* _session; }; diff --git a/libs/surfaces/faderport8/actions.cc b/libs/surfaces/faderport8/actions.cc index 476a48b5c6..cae4b4e05b 100644 --- a/libs/surfaces/faderport8/actions.cc +++ b/libs/surfaces/faderport8/actions.cc @@ -571,11 +571,11 @@ FaderPort8::button_encoder () * the current position and we're not rolling. */ samplepos_t where = _session->audible_sample(); - if (_session->transport_stopped_or_stopping() && _session->locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { + if (_session->transport_stopped_or_stopping() && locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { return; } - _session->locations()->next_available_name (markername,"mark"); + locations()->next_available_name (markername,"mark"); add_marker (markername); } break; diff --git a/libs/surfaces/faderport8/callbacks.cc b/libs/surfaces/faderport8/callbacks.cc index 4278277829..b8fcadc63c 100644 --- a/libs/surfaces/faderport8/callbacks.cc +++ b/libs/surfaces/faderport8/callbacks.cc @@ -168,7 +168,7 @@ void FaderPort8::notify_loop_state_changed () { bool looping = false; - Location* looploc = _session->locations ()->auto_loop_location (); + Location* looploc = locations ()->auto_loop_location (); if (looploc && get_play_loop ()) { looping = true; } diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index a1b10bf9ed..1fc783256a 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -485,11 +485,11 @@ MackieControlProtocol::marker_release (Button &) samplepos_t where = _session->audible_sample(); - if (_session->transport_stopped_or_stopping() && _session->locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { + if (_session->transport_stopped_or_stopping() && locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { return off; } - _session->locations()->next_available_name (markername,"mark"); + locations()->next_available_name (markername,"mark"); add_marker (markername); return off; diff --git a/libs/surfaces/maschine2/callbacks.cc b/libs/surfaces/maschine2/callbacks.cc index dbadb4d64e..81e7c1fa62 100644 --- a/libs/surfaces/maschine2/callbacks.cc +++ b/libs/surfaces/maschine2/callbacks.cc @@ -139,7 +139,7 @@ void Maschine2::notify_loop_state_changed () { bool looping = false; - Location* looploc = _session->locations ()->auto_loop_location (); + Location* looploc = locations ()->auto_loop_location (); if (looploc && get_play_loop ()) { looping = true; } diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index eb76dab0e8..4d79b3c896 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1305,7 +1305,7 @@ OSC::osc_toggle_roll (bool ret2strt) } else { if (get_play_loop() && Config->get_loop_is_mode()) { - locate (_session->locations()->auto_loop_location()->start().samples(), MustRoll); + locate (locations()->auto_loop_location()->start().samples(), MustRoll); } else { _session->request_roll (TRS_UI); } @@ -3139,7 +3139,7 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg) PBD::warning << "Wrong number of parameters, one only." << endmsg; return -1; } - const Locations::LocationList& ll (_session->locations ()->list ()); + const Locations::LocationList& ll (locations ()->list ()); uint32_t marker = 0; switch (types[0]) { diff --git a/libs/surfaces/osc/osc_global_observer.cc b/libs/surfaces/osc/osc_global_observer.cc index aadf6563d1..4f4ed1aeb3 100644 --- a/libs/surfaces/osc/osc_global_observer.cc +++ b/libs/surfaces/osc/osc_global_observer.cc @@ -427,7 +427,7 @@ void OSCGlobalObserver::marks_changed () { lm.clear(); - const Locations::LocationList& ll (session->locations ()->list ()); + const Locations::LocationList& ll (_osc.locations ()->list ()); // get Locations that are marks for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) { if ((*l)->is_session_range ()) { diff --git a/libs/surfaces/tranzport/general.cc b/libs/surfaces/tranzport/general.cc index 35b62a7710..85964ad833 100644 --- a/libs/surfaces/tranzport/general.cc +++ b/libs/surfaces/tranzport/general.cc @@ -181,7 +181,7 @@ TranzportControlProtocol::update_state () void TranzportControlProtocol::prev_marker () { - Location *location = session->locations()->first_location_before (transport_sample()); + Location *location = locations()->first_location_before (transport_sample()); if (location) { locate (location->start()); @@ -196,7 +196,7 @@ TranzportControlProtocol::prev_marker () void TranzportControlProtocol::next_marker () { - Location *location = session->locations()->first_location_after (transport_sample()); + Location *location = locations()->first_location_after (transport_sample()); if (location) { locate (location->start()); diff --git a/libs/surfaces/us2400/mcp_buttons.cc b/libs/surfaces/us2400/mcp_buttons.cc index ae4ba3790b..cadb8d3ac0 100644 --- a/libs/surfaces/us2400/mcp_buttons.cc +++ b/libs/surfaces/us2400/mcp_buttons.cc @@ -458,11 +458,11 @@ US2400Protocol::marker_release (Button &) samplepos_t where = _session->audible_sample(); - if (_session->transport_stopped_or_stopping() && _session->locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { + if (_session->transport_stopped_or_stopping() && locations()->mark_at (timepos_t (where), timecnt_t (_session->sample_rate() / 100.0))) { return off; } - _session->locations()->next_available_name (markername,"mark"); + locations()->next_available_name (markername,"mark"); add_marker (markername); return off;