ControlProtocol doesn't actually need any record of an event loop and doesn't need to connect to any signals itself

git-svn-id: svn://localhost/ardour2/branches/3.0@12063 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-23 10:54:34 +00:00
parent 19a197ecbc
commit 4bfdcc18bd
8 changed files with 24 additions and 55 deletions

View File

@ -50,34 +50,17 @@ PBD::Signal1<void,uint32_t> ControlProtocol::SetRouteSelection;
PBD::Signal1<void,uint32_t> ControlProtocol::RemoveRouteFromSelection;
PBD::Signal0<void> ControlProtocol::ClearRouteSelection;
ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop)
: BasicUI (s),
_name (str)
ControlProtocol::ControlProtocol (Session& s, string str)
: BasicUI (s)
, _name (str)
, _active (false)
{
if (evloop) {
_own_event_loop = false;
_event_loop = evloop;
} else {
_own_event_loop = true;
fatal << "programming error: cannot create control protocols without an existing event loop (yet)" << endmsg;
/*NOTREACHED*/
}
_active = false;
session->RouteAdded.connect (*this, MISSING_INVALIDATOR, boost::protect (boost::bind (&ControlProtocol::add_strip, this, _1)), _event_loop);
}
ControlProtocol::~ControlProtocol ()
{
}
void
ControlProtocol::add_strip (ARDOUR::RouteList&)
{
route_list_changed();
}
void
ControlProtocol::next_track (uint32_t initial_id)
{

View File

@ -39,9 +39,9 @@ class Route;
class Session;
class Bundle;
class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
class ControlProtocol : public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
public:
ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop);
ControlProtocol (Session&, std::string name);
virtual ~ControlProtocol();
std::string name() const { return _name; }
@ -52,8 +52,6 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu
virtual int set_feedback (bool /*yn*/) { return 0; }
virtual bool get_feedback () const { return false; }
virtual void route_list_changed () {}
virtual void midi_connectivity_established () {}
PBD::Signal0<void> ActiveChanged;
@ -132,14 +130,10 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu
virtual void tear_down_gui() { }
protected:
PBD::EventLoop* _event_loop;
bool _own_event_loop;
std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
std::string _name;
bool _active;
void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >&);
void next_track (uint32_t initial_id);
void prev_track (uint32_t initial_id);

View File

@ -54,7 +54,7 @@ using namespace std;
#define ui_bind(x) boost::protect (boost::bind ((x)))
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
: ControlProtocol (s, _("Generic MIDI"), midi_ui_context())
: ControlProtocol (s, _("Generic MIDI"))
, _motorised (false)
, gui (0)
{

View File

@ -93,7 +93,7 @@ bool MackieControlProtocol::probe()
}
MackieControlProtocol::MackieControlProtocol (Session& session)
: ControlProtocol (session, X_("Mackie"), this)
: ControlProtocol (session, X_("Mackie"))
, AbstractUI<MackieControlUIRequest> ("mackie")
, _current_initial_bank (0)
, _timecode_type (ARDOUR::AnyTime::BBT)
@ -164,9 +164,9 @@ MackieControlProtocol::thread_init ()
void
MackieControlProtocol::midi_connectivity_established ()
{
/* may need to tell surfaces because they may need to wake up the
* device
*/
for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
(*si)->say_hello ();
}
}
// go to the previous track.

View File

@ -61,9 +61,6 @@ using namespace PBD;
#define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int);
#define invalidator() __invalidator (*(MackieControlProtocol::instance()), __FILE__, __LINE__)
Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::ID,StripButtonInfo>& strip_buttons)
: Group (name)
, _solo (0)
@ -168,23 +165,23 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
set_vpot_parameter (PanAzimuthAutomation);
_route->solo_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_solo_changed, this), ui_context());
_route->mute_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_mute_changed, this), ui_context());
_route->solo_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_solo_changed, this), ui_context());
_route->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_mute_changed, this), ui_context());
boost::shared_ptr<Pannable> pannable = _route->pannable();
if (pannable) {
pannable->pan_azimuth_control->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
pannable->pan_width_control->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_panner_width_changed, this, false), ui_context());
pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_width_changed, this, false), ui_context());
}
_route->gain_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_gain_changed, this, false), ui_context());
_route->PropertyChanged.connect (route_connections, invalidator(), ui_bind (&Strip::notify_property_changed, this, _1), ui_context());
_route->gain_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_gain_changed, this, false), ui_context());
_route->PropertyChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_property_changed, this, _1), ui_context());
boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
if (trk) {
_recenable->set_control (trk->rec_enable_control());
trk->rec_enable_control()->Changed .connect(route_connections, invalidator(), ui_bind (&Strip::notify_record_enable_changed, this), ui_context());
trk->rec_enable_control()->Changed .connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_record_enable_changed, this), ui_context());
}
@ -192,8 +189,8 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
// TODO this works when a currently-banked route is made inactive, but not
// when a route is activated which should be currently banked.
_route->active_changed.connect (route_connections, invalidator(), ui_bind (&Strip::notify_active_changed, this), ui_context());
_route->DropReferences.connect (route_connections, invalidator(), ui_bind (&Strip::notify_route_deleted, this), ui_context());
_route->active_changed.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_active_changed, this), ui_context());
_route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_route_deleted, this), ui_context());
/* Update */

View File

@ -43,8 +43,6 @@ using ARDOUR::AutomationControl;
#define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int);
#define invalidator() __invalidator (*(MackieControlProtocol::instance()), __FILE__, __LINE__)
// The MCU sysex header.4th byte Will be overwritten
// when we get an incoming sysex that identifies
@ -208,7 +206,7 @@ Surface::setup_master ()
}
_master_fader->set_control (m->gain_control());
m->gain_control()->Changed.connect (*this, invalidator(), ui_bind (&Surface::master_gain_changed, this), ui_context());
m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, ui_bind (&Surface::master_gain_changed, this), ui_context());
}
void
@ -796,8 +794,7 @@ Surface::gui_selection_changed (ARDOUR::RouteNotificationListPtr routes)
void
Surface::say_hello ()
{
/* wakey wakey */
/* wakeup for Mackie Control */
MidiByteArray wakeup (7, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x00, MIDI::eox);
_port->write (wakeup);
wakeup[4] = 0x15; /* wakup Mackie XT */
@ -806,8 +803,6 @@ Surface::say_hello ()
_port->write (wakeup);
wakeup[4] = 0x11; /* wakeup Logic Control XT */
_port->write (wakeup);
zero_all ();
}
void

View File

@ -73,7 +73,7 @@ static void error_callback(int, const char *, const char *)
#endif
OSC::OSC (Session& s, uint32_t port)
: ControlProtocol (s, "OSC", this)
: ControlProtocol (s, "OSC")
, AbstractUI<OSCUIRequest> ("osc")
, _port(port)
{

View File

@ -91,7 +91,7 @@ int find_powermate(int mode)
}
PowermateControlProtocol::PowermateControlProtocol (Session& s)
: ControlProtocol (s, "powermate", 0 /* XXX need an event loop here */)
: ControlProtocol (s, "powermate")
{
}