Add BasicUI::master_out() and BasicUI::monitor_out()

Towards removing the direct use of Session by surfaces.
This commit is contained in:
David Robillard 2021-06-15 19:59:23 -04:00
parent b35f9ca1a0
commit 0dc7cbba14
21 changed files with 72 additions and 55 deletions

View file

@ -1052,8 +1052,8 @@ void
CC121::drop_current_stripable () CC121::drop_current_stripable ()
{ {
if (_current_stripable) { if (_current_stripable) {
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
set_current_stripable (_session->master_out()); set_current_stripable (master_out ());
} else { } else {
set_current_stripable (boost::shared_ptr<Stripable>()); set_current_stripable (boost::shared_ptr<Stripable>());
} }
@ -1255,7 +1255,7 @@ CC121::map_stripable_state ()
map_auto (); map_auto ();
map_monitoring (); map_monitoring ();
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
map_cut (); map_cut ();
} else { } else {
map_mute (); map_mute ();

View file

@ -157,7 +157,7 @@ CC121::mute ()
return; return;
} }
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control(); boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
mp->set_cut_all (!mp->cut_all()); mp->set_cut_all (!mp->cut_all());
return; return;
@ -194,7 +194,7 @@ CC121::rec_enable ()
void void
CC121::use_master () CC121::use_master ()
{ {
boost::shared_ptr<Stripable> r = _session->master_out(); boost::shared_ptr<Stripable> r = master_out ();
if (r) { if (r) {
if (_current_stripable == r) { if (_current_stripable == r) {
r = pre_master_stripable.lock(); r = pre_master_stripable.lock();
@ -202,7 +202,7 @@ CC121::use_master ()
get_button(Output).set_led_state (_output_port, false); get_button(Output).set_led_state (_output_port, false);
blinkers.remove (Output); blinkers.remove (Output);
} else { } else {
if (_current_stripable != _session->master_out() && _current_stripable != _session->monitor_out()) { if (_current_stripable != master_out () && _current_stripable != monitor_out ()) {
pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable); pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable);
} }
set_current_stripable (r); set_current_stripable (r);
@ -215,7 +215,7 @@ CC121::use_master ()
void void
CC121::use_monitor () CC121::use_monitor ()
{ {
boost::shared_ptr<Stripable> r = _session->monitor_out(); boost::shared_ptr<Stripable> r = monitor_out ();
if (r) { if (r) {
if (_current_stripable == r) { if (_current_stripable == r) {
@ -224,7 +224,7 @@ CC121::use_monitor ()
get_button(Output).set_led_state (_output_port, false); get_button(Output).set_led_state (_output_port, false);
blinkers.remove (Output); blinkers.remove (Output);
} else { } else {
if (_current_stripable != _session->master_out() && _current_stripable != _session->monitor_out()) { if (_current_stripable != master_out () && _current_stripable != monitor_out ()) {
pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable); pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable);
} }
set_current_stripable (r); set_current_stripable (r);

View file

@ -828,3 +828,15 @@ BasicUI::config ()
{ {
return _session->config; return _session->config;
} }
boost::shared_ptr<Stripable>
BasicUI::monitor_out () const
{
return _session->monitor_out ();
}
boost::shared_ptr<Stripable>
BasicUI::master_out () const
{
return _session->master_out ();
}

View file

@ -38,6 +38,7 @@
namespace ARDOUR { namespace ARDOUR {
class Route;
class Session; class Session;
class SessionConfiguration; class SessionConfiguration;
@ -172,6 +173,11 @@ class LIBCONTROLCP_API BasicUI {
const SessionConfiguration& config () const; const SessionConfiguration& config () const;
SessionConfiguration& config (); SessionConfiguration& config ();
/* Monitor/Master Out */
boost::shared_ptr<Stripable> monitor_out () const;
boost::shared_ptr<Stripable> master_out () const;
protected: protected:
Session* _session; Session* _session;
}; };

View file

@ -1096,8 +1096,8 @@ void
FaderPort::drop_current_stripable () FaderPort::drop_current_stripable ()
{ {
if (_current_stripable) { if (_current_stripable) {
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
set_current_stripable (_session->master_out()); set_current_stripable (master_out ());
} else { } else {
set_current_stripable (boost::shared_ptr<Stripable>()); set_current_stripable (boost::shared_ptr<Stripable>());
} }
@ -1299,7 +1299,7 @@ FaderPort::map_stripable_state ()
map_gain (); map_gain ();
map_auto (); map_auto ();
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
map_cut (); map_cut ();
} else { } else {
map_mute (); map_mute ();

View file

@ -124,7 +124,7 @@ FaderPort::mute ()
return; return;
} }
if (_current_stripable == _session->monitor_out()) { if (_current_stripable == monitor_out ()) {
boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control(); boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
mp->set_cut_all (!mp->cut_all()); mp->set_cut_all (!mp->cut_all());
return; return;
@ -162,7 +162,7 @@ FaderPort::rec_enable ()
void void
FaderPort::use_master () FaderPort::use_master ()
{ {
boost::shared_ptr<Stripable> r = _session->master_out(); boost::shared_ptr<Stripable> r = master_out ();
if (r) { if (r) {
if (_current_stripable == r) { if (_current_stripable == r) {
r = pre_master_stripable.lock(); r = pre_master_stripable.lock();
@ -170,7 +170,7 @@ FaderPort::use_master ()
get_button(Output).set_led_state (_output_port, false); get_button(Output).set_led_state (_output_port, false);
blinkers.remove (Output); blinkers.remove (Output);
} else { } else {
if (_current_stripable != _session->master_out() && _current_stripable != _session->monitor_out()) { if (_current_stripable != master_out () && _current_stripable != monitor_out ()) {
pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable); pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable);
} }
set_current_stripable (r); set_current_stripable (r);
@ -183,7 +183,7 @@ FaderPort::use_master ()
void void
FaderPort::use_monitor () FaderPort::use_monitor ()
{ {
boost::shared_ptr<Stripable> r = _session->monitor_out(); boost::shared_ptr<Stripable> r = monitor_out ();
if (r) { if (r) {
if (_current_stripable == r) { if (_current_stripable == r) {
@ -192,7 +192,7 @@ FaderPort::use_monitor ()
get_button(Output).set_led_state (_output_port, false); get_button(Output).set_led_state (_output_port, false);
blinkers.remove (Output); blinkers.remove (Output);
} else { } else {
if (_current_stripable != _session->master_out() && _current_stripable != _session->monitor_out()) { if (_current_stripable != master_out () && _current_stripable != monitor_out ()) {
pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable); pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable);
} }
set_current_stripable (r); set_current_stripable (r);

View file

@ -549,9 +549,9 @@ FaderPort8::button_encoder ()
/* master || monitor level -- reset to 0dB */ /* master || monitor level -- reset to 0dB */
boost::shared_ptr<AutomationControl> ac; boost::shared_ptr<AutomationControl> ac;
if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) { if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
ac = _session->monitor_out()->gain_control (); ac = monitor_out ()->gain_control ();
} else if (_session->master_out()) { } else if (master_out ()) {
ac = _session->master_out()->gain_control (); ac = master_out ()->gain_control ();
} }
if (ac) { if (ac) {
ac->start_touch (timepos_t (transport_sample())); ac->start_touch (timepos_t (transport_sample()));
@ -629,9 +629,9 @@ FaderPort8::encoder_navigate (bool neg, int steps)
/* master || monitor level */ /* master || monitor level */
boost::shared_ptr<AutomationControl> ac; boost::shared_ptr<AutomationControl> ac;
if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) { if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
ac = _session->monitor_out()->gain_control (); ac = monitor_out ()->gain_control ();
} else if (_session->master_out()) { } else if (master_out ()) {
ac = _session->master_out()->gain_control (); ac = master_out ()->gain_control ();
} }
if (ac) { if (ac) {
double v = ac->internal_to_interface (ac->get_value()); double v = ac->internal_to_interface (ac->get_value());

View file

@ -1116,9 +1116,9 @@ GenericMidiControlProtocol::lookup_controllable (const string & str) const
name = rest[0]; name = rest[0];
if (name == "Master" || name == X_("master")) { if (name == "Master" || name == X_("master")) {
s = _session->master_out(); s = master_out ();
} else if (name == X_("control") || name == X_("listen") || name == X_("monitor") || name == "Monitor") { } else if (name == X_("control") || name == X_("listen") || name == X_("monitor") || name == "Monitor") {
s = _session->monitor_out(); s = monitor_out ();
} else if (name == X_("auditioner")) { } else if (name == X_("auditioner")) {
s = _session->the_auditioner(); s = _session->the_auditioner();
} else { } else {

View file

@ -94,7 +94,7 @@ LaunchControlXL::LaunchControlXL (ARDOUR::Session& s)
/* we're going to need this */ /* we're going to need this */
/* master cannot be removed, so no need to connect to going-away signal */ /* master cannot be removed, so no need to connect to going-away signal */
master = _session->master_out (); master = master_out ();
run_event_loop (); run_event_loop ();

View file

@ -1843,13 +1843,13 @@ MackieControlProtocol::set_flip_mode (FlipMode fm)
void void
MackieControlProtocol::set_master_on_surface_strip (uint32_t surface, uint32_t strip_number) MackieControlProtocol::set_master_on_surface_strip (uint32_t surface, uint32_t strip_number)
{ {
force_special_stripable_to_strip (_session->master_out(), surface, strip_number); force_special_stripable_to_strip (master_out (), surface, strip_number);
} }
void void
MackieControlProtocol::set_monitor_on_surface_strip (uint32_t surface, uint32_t strip_number) MackieControlProtocol::set_monitor_on_surface_strip (uint32_t surface, uint32_t strip_number)
{ {
force_special_stripable_to_strip (_session->monitor_out(), surface, strip_number); force_special_stripable_to_strip (monitor_out (), surface, strip_number);
} }
void void
@ -1865,7 +1865,7 @@ MackieControlProtocol::force_special_stripable_to_strip (boost::shared_ptr<Strip
if ((*s)->number() == surface) { if ((*s)->number() == surface) {
Strip* strip = (*s)->nth_strip (strip_number); Strip* strip = (*s)->nth_strip (strip_number);
if (strip) { if (strip) {
strip->set_stripable (_session->master_out()); strip->set_stripable (master_out ());
strip->lock_controls (); strip->lock_controls ();
} }
} }

View file

@ -413,8 +413,8 @@ Surface::master_monitor_may_have_changed ()
void void
Surface::setup_master () Surface::setup_master ()
{ {
if ((_master_stripable = _mcp.get_session().monitor_out()) == 0) { if ((_master_stripable = _mcp.monitor_out()) == 0) {
_master_stripable = _mcp.get_session().master_out(); _master_stripable = _mcp.master_out();
} }
if (!_master_stripable) { if (!_master_stripable) {

View file

@ -362,7 +362,7 @@ Maschine2::encoder_master (int delta)
break; break;
case MST_VOLUME: case MST_VOLUME:
{ {
boost::shared_ptr<Route> master = _session->master_out (); boost::shared_ptr<Stripable> master = master_out ();
if (master) { if (master) {
// TODO consider _ctrl->button (M2Contols::EncoderWheel)->is_pressed() for fine grained // TODO consider _ctrl->button (M2Contols::EncoderWheel)->is_pressed() for fine grained
const double factor = _ctrl->button (M2Contols::BtnShift, M2Contols::ModNone)->active () ? 256. : 32.; const double factor = _ctrl->button (M2Contols::BtnShift, M2Contols::ModNone)->active () ? 256. : 32.;

View file

@ -77,8 +77,8 @@ class TestLayout : public Maschine2Layout
knob = new Maschine2Knob(&m2, this); knob = new Maschine2Knob(&m2, this);
knob->set_position (Duple (64 + 32, 32)); knob->set_position (Duple (64 + 32, 32));
if (_session.master_out ()) { if (m2.master_out ()) {
knob->set_controllable (_session.master_out ()->gain_control()); knob->set_controllable (m2.master_out ()->gain_control());
} }
std::vector<std::string> strs; std::vector<std::string> strs;

View file

@ -276,7 +276,7 @@ OSC::start ()
_select = ControlProtocol::first_selected_stripable(); _select = ControlProtocol::first_selected_stripable();
if(!_select) { if(!_select) {
_select = _session->master_out (); _select = master_out ();
} }
return 0; return 0;
@ -1116,7 +1116,7 @@ OSC::routes_list (lo_message msg)
lo_message_add_string (reply, X_("end_route_list")); lo_message_add_string (reply, X_("end_route_list"));
lo_message_add_int64 (reply, _session->sample_rate()); lo_message_add_int64 (reply, _session->sample_rate());
lo_message_add_int64 (reply, _session->current_end_sample()); lo_message_add_int64 (reply, _session->current_end_sample());
if (_session->monitor_out()) { if (monitor_out ()) {
// this session has a monitor section // this session has a monitor section
lo_message_add_int32 (reply, 1); lo_message_add_int32 (reply, 1);
} else { } else {
@ -3368,7 +3368,7 @@ OSC::master_parse (const char *path, const char* types, lo_arg **argv, int argc,
} }
//OSCSurface *sur = get_surface(get_address (msg)); //OSCSurface *sur = get_surface(get_address (msg));
boost::shared_ptr<Stripable> s = _session->master_out(); boost::shared_ptr<Stripable> s = master_out();
if (s) { if (s) {
ret = _strip_parse (path, sub_path, types, argv, argc, s, 0, false, msg); ret = _strip_parse (path, sub_path, types, argv, argc, s, 0, false, msg);
} else { } else {
@ -3395,9 +3395,9 @@ OSC::monitor_parse (const char *path, const char* types, lo_arg **argv, int argc
} }
//OSCSurface *sur = get_surface(get_address (msg)); //OSCSurface *sur = get_surface(get_address (msg));
boost::shared_ptr<Stripable> s = _session->monitor_out(); boost::shared_ptr<Stripable> s = monitor_out ();
if (s) { if (s) {
boost::shared_ptr<MonitorProcessor> mon = _session->monitor_out()->monitor_control(); boost::shared_ptr<MonitorProcessor> mon = monitor_out ()->monitor_control();
int state = 0; int state = 0;
if (types[0] == 'f') { if (types[0] == 'f') {
state = (uint32_t) argv[0]->f; state = (uint32_t) argv[0]->f;
@ -4714,7 +4714,7 @@ OSC::_strip_select2 (boost::shared_ptr<Stripable> s, OSCSurface *sur, lo_address
if (ControlProtocol::first_selected_stripable()) { if (ControlProtocol::first_selected_stripable()) {
s = ControlProtocol::first_selected_stripable(); s = ControlProtocol::first_selected_stripable();
} else { } else {
s = _session->master_out (); s = master_out ();
} }
_select = s; _select = s;
} }
@ -6126,13 +6126,13 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sor
if (!custom) { if (!custom) {
// Master/Monitor might be anywhere... we put them at the end - Sorry ;) // Master/Monitor might be anywhere... we put them at the end - Sorry ;)
if (types[5]) { if (types[5]) {
if (_session->master_out()) { if (master_out ()) {
sorted.push_back (_session->master_out()); sorted.push_back (master_out());
} }
} }
if (types[6]) { if (types[6]) {
if (_session->monitor_out()) { if (monitor_out ()) {
sorted.push_back (_session->monitor_out()); sorted.push_back (monitor_out ());
} }
} }
} }

View file

@ -67,7 +67,7 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS
// Master channel first // Master channel first
_osc.text_message (X_("/master/name"), "Master", addr); _osc.text_message (X_("/master/name"), "Master", addr);
boost::shared_ptr<Stripable> strip = session->master_out(); boost::shared_ptr<Stripable> strip = _osc.master_out ();
boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(strip->mute_control()); boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(strip->mute_control());
mute_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/mute"), strip->mute_control()), OSC::instance()); mute_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/mute"), strip->mute_control()), OSC::instance());
@ -88,7 +88,7 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS
send_gain_message (X_("/master/"), gain_controllable); send_gain_message (X_("/master/"), gain_controllable);
// monitor stuff next // monitor stuff next
strip = session->monitor_out(); strip = _osc.monitor_out();
if (strip) { if (strip) {
_osc.text_message (X_("/monitor/name"), "Monitor", addr); _osc.text_message (X_("/monitor/name"), "Monitor", addr);
@ -301,7 +301,7 @@ OSCGlobalObserver::tick ()
} }
if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
// the only meter here is master // the only meter here is master
float now_meter = session->master_out()->peak_meter()->meter_level(0, MeterMCP); float now_meter = _osc.master_out()->peak_meter()->meter_level(0, MeterMCP);
if (now_meter < -94) now_meter = -193; if (now_meter < -94) now_meter = -193;
if (_last_meter != now_meter) { if (_last_meter != now_meter) {
if (feedback[7] || feedback[8]) { if (feedback[7] || feedback[8]) {

View file

@ -25,7 +25,6 @@
#include <glibmm.h> #include <glibmm.h>
#include "ardour/session.h"
#include "ardour/track.h" #include "ardour/track.h"
#include "ardour/monitor_control.h" #include "ardour/monitor_control.h"
#include "ardour/dB.h" #include "ardour/dB.h"

View file

@ -739,7 +739,7 @@ Push2::button_mix_press ()
void void
Push2::button_master () Push2::button_master ()
{ {
boost::shared_ptr<Stripable> main_out = _session->master_out (); boost::shared_ptr<Stripable> main_out = master_out ();
if (!main_out) { if (!main_out) {
return; return;

View file

@ -108,7 +108,7 @@ Push2::Push2 (ARDOUR::Session& s)
fill_color_table (); fill_color_table ();
/* master cannot be removed, so no need to connect to going-away signal */ /* master cannot be removed, so no need to connect to going-away signal */
master = _session->master_out (); master = master_out ();
/* allocate graphics layouts, even though we're not using them yet */ /* allocate graphics layouts, even though we're not using them yet */

View file

@ -772,7 +772,7 @@ LedState
US2400Protocol::mstr_press (Button &) US2400Protocol::mstr_press (Button &)
{ {
// access_action("Mixer/select-none"); // access_action("Mixer/select-none");
set_stripable_selection( _session->master_out() ); set_stripable_selection (master_out());
return on; return on;
} }

View file

@ -371,8 +371,8 @@ Surface::setup_master ()
{ {
boost::shared_ptr<Stripable> m; boost::shared_ptr<Stripable> m;
if ((m = _mcp.get_session().monitor_out()) == 0) { if ((m = _mcp.monitor_out()) == 0) {
m = _mcp.get_session().master_out(); m = _mcp.master_out();
} }
if (!m) { if (!m) {

View file

@ -1496,13 +1496,13 @@ US2400Protocol::display_view_mode ()
void void
US2400Protocol::set_master_on_surface_strip (uint32_t surface, uint32_t strip_number) US2400Protocol::set_master_on_surface_strip (uint32_t surface, uint32_t strip_number)
{ {
force_special_stripable_to_strip (_session->master_out(), surface, strip_number); force_special_stripable_to_strip (master_out (), surface, strip_number);
} }
void void
US2400Protocol::set_monitor_on_surface_strip (uint32_t surface, uint32_t strip_number) US2400Protocol::set_monitor_on_surface_strip (uint32_t surface, uint32_t strip_number)
{ {
force_special_stripable_to_strip (_session->monitor_out(), surface, strip_number); force_special_stripable_to_strip (monitor_out (), surface, strip_number);
} }
void void
@ -1518,7 +1518,7 @@ US2400Protocol::force_special_stripable_to_strip (boost::shared_ptr<Stripable> r
if ((*s)->number() == surface) { if ((*s)->number() == surface) {
Strip* strip = (*s)->nth_strip (strip_number); Strip* strip = (*s)->nth_strip (strip_number);
if (strip) { if (strip) {
strip->set_stripable (_session->master_out()); strip->set_stripable (master_out ());
strip->lock_controls (); strip->lock_controls ();
} }
} }