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 ()
{
if (_current_stripable) {
if (_current_stripable == _session->monitor_out()) {
set_current_stripable (_session->master_out());
if (_current_stripable == monitor_out ()) {
set_current_stripable (master_out ());
} else {
set_current_stripable (boost::shared_ptr<Stripable>());
}
@ -1255,7 +1255,7 @@ CC121::map_stripable_state ()
map_auto ();
map_monitoring ();
if (_current_stripable == _session->monitor_out()) {
if (_current_stripable == monitor_out ()) {
map_cut ();
} else {
map_mute ();

View file

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

View file

@ -828,3 +828,15 @@ BasicUI::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 {
class Route;
class Session;
class SessionConfiguration;
@ -172,6 +173,11 @@ class LIBCONTROLCP_API BasicUI {
const SessionConfiguration& config () const;
SessionConfiguration& config ();
/* Monitor/Master Out */
boost::shared_ptr<Stripable> monitor_out () const;
boost::shared_ptr<Stripable> master_out () const;
protected:
Session* _session;
};

View file

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

View file

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

View file

@ -549,9 +549,9 @@ FaderPort8::button_encoder ()
/* master || monitor level -- reset to 0dB */
boost::shared_ptr<AutomationControl> ac;
if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
ac = _session->monitor_out()->gain_control ();
} else if (_session->master_out()) {
ac = _session->master_out()->gain_control ();
ac = monitor_out ()->gain_control ();
} else if (master_out ()) {
ac = master_out ()->gain_control ();
}
if (ac) {
ac->start_touch (timepos_t (transport_sample()));
@ -629,9 +629,9 @@ FaderPort8::encoder_navigate (bool neg, int steps)
/* master || monitor level */
boost::shared_ptr<AutomationControl> ac;
if (_session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
ac = _session->monitor_out()->gain_control ();
} else if (_session->master_out()) {
ac = _session->master_out()->gain_control ();
ac = monitor_out ()->gain_control ();
} else if (master_out ()) {
ac = master_out ()->gain_control ();
}
if (ac) {
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];
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") {
s = _session->monitor_out();
s = monitor_out ();
} else if (name == X_("auditioner")) {
s = _session->the_auditioner();
} else {

View file

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

View file

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

View file

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

View file

@ -362,7 +362,7 @@ Maschine2::encoder_master (int delta)
break;
case MST_VOLUME:
{
boost::shared_ptr<Route> master = _session->master_out ();
boost::shared_ptr<Stripable> master = master_out ();
if (master) {
// TODO consider _ctrl->button (M2Contols::EncoderWheel)->is_pressed() for fine grained
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->set_position (Duple (64 + 32, 32));
if (_session.master_out ()) {
knob->set_controllable (_session.master_out ()->gain_control());
if (m2.master_out ()) {
knob->set_controllable (m2.master_out ()->gain_control());
}
std::vector<std::string> strs;

View file

@ -276,7 +276,7 @@ OSC::start ()
_select = ControlProtocol::first_selected_stripable();
if(!_select) {
_select = _session->master_out ();
_select = master_out ();
}
return 0;
@ -1116,7 +1116,7 @@ OSC::routes_list (lo_message msg)
lo_message_add_string (reply, X_("end_route_list"));
lo_message_add_int64 (reply, _session->sample_rate());
lo_message_add_int64 (reply, _session->current_end_sample());
if (_session->monitor_out()) {
if (monitor_out ()) {
// this session has a monitor section
lo_message_add_int32 (reply, 1);
} 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));
boost::shared_ptr<Stripable> s = _session->master_out();
boost::shared_ptr<Stripable> s = master_out();
if (s) {
ret = _strip_parse (path, sub_path, types, argv, argc, s, 0, false, msg);
} 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));
boost::shared_ptr<Stripable> s = _session->monitor_out();
boost::shared_ptr<Stripable> s = monitor_out ();
if (s) {
boost::shared_ptr<MonitorProcessor> mon = _session->monitor_out()->monitor_control();
boost::shared_ptr<MonitorProcessor> mon = monitor_out ()->monitor_control();
int state = 0;
if (types[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()) {
s = ControlProtocol::first_selected_stripable();
} else {
s = _session->master_out ();
s = master_out ();
}
_select = s;
}
@ -6126,13 +6126,13 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sor
if (!custom) {
// Master/Monitor might be anywhere... we put them at the end - Sorry ;)
if (types[5]) {
if (_session->master_out()) {
sorted.push_back (_session->master_out());
if (master_out ()) {
sorted.push_back (master_out());
}
}
if (types[6]) {
if (_session->monitor_out()) {
sorted.push_back (_session->monitor_out());
if (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
_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());
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);
// monitor stuff next
strip = session->monitor_out();
strip = _osc.monitor_out();
if (strip) {
_osc.text_message (X_("/monitor/name"), "Monitor", addr);
@ -301,7 +301,7 @@ OSCGlobalObserver::tick ()
}
if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
// 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 (_last_meter != now_meter) {
if (feedback[7] || feedback[8]) {

View file

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

View file

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

View file

@ -108,7 +108,7 @@ Push2::Push2 (ARDOUR::Session& s)
fill_color_table ();
/* 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 */

View file

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

View file

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

View file

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