summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/control_protocol/control_protocol.cc29
-rw-r--r--libs/surfaces/control_protocol/control_protocol/control_protocol.h6
-rw-r--r--libs/surfaces/generic_midi/generic_midi_control_protocol.cc101
-rw-r--r--libs/surfaces/generic_midi/generic_midi_control_protocol.h5
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc19
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc30
-rw-r--r--libs/surfaces/mackie/mackie_port.cc4
-rw-r--r--libs/surfaces/mackie/route_signal.cc20
-rw-r--r--libs/surfaces/osc/osc.cc13
-rw-r--r--libs/surfaces/osc/osc.h6
-rw-r--r--libs/surfaces/osc/osc_controllable.cc3
-rw-r--r--libs/surfaces/osc/osc_controllable.h4
-rw-r--r--libs/surfaces/powermate/powermate.cc2
13 files changed, 129 insertions, 113 deletions
diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc
index d7f9d52efd..ff6de6b274 100644
--- a/libs/surfaces/control_protocol/control_protocol.cc
+++ b/libs/surfaces/control_protocol/control_protocol.cc
@@ -18,6 +18,8 @@
*/
+#include "pbd/error.h"
+
#include "ardour/session.h"
#include "ardour/route.h"
#include "ardour/audio_track.h"
@@ -27,19 +29,30 @@
using namespace ARDOUR;
using namespace std;
+using namespace PBD;
-PBD::Signal0<void> ControlProtocol::ZoomToSession;
-PBD::Signal0<void> ControlProtocol::ZoomOut;
-PBD::Signal0<void> ControlProtocol::ZoomIn;
-PBD::Signal0<void> ControlProtocol::Enter;
-PBD::Signal1<void,float> ControlProtocol::ScrollTimeline;
+Signal0<void> ControlProtocol::ZoomToSession;
+Signal0<void> ControlProtocol::ZoomOut;
+Signal0<void> ControlProtocol::ZoomIn;
+Signal0<void> ControlProtocol::Enter;
+Signal1<void,float> ControlProtocol::ScrollTimeline;
-ControlProtocol::ControlProtocol (Session& s, string str)
+ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop)
: BasicUI (s),
_name (str)
{
+ 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, boost::bind (&ControlProtocol::add_strip, this, _1));
+
+ session->RouteAdded.connect (*this, boost::protect (boost::bind (&ControlProtocol::add_strip, this, _1)), _event_loop);
}
ControlProtocol::~ControlProtocol ()
@@ -47,7 +60,7 @@ ControlProtocol::~ControlProtocol ()
}
void
-ControlProtocol::add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >)
+ControlProtocol::add_strip (ARDOUR::RouteList&)
{
route_list_changed();
}
diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h
index c80ba9b4b6..b3d44a15aa 100644
--- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h
+++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h
@@ -36,7 +36,7 @@ class Session;
class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
public:
- ControlProtocol (Session&, std::string name);
+ ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop);
virtual ~ControlProtocol();
std::string name() const { return _name; }
@@ -99,11 +99,13 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu
std::string route_get_name (uint32_t table_index);
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 add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >&);
void next_track (uint32_t initial_id);
void prev_track (uint32_t initial_id);
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
index e9f12638b6..c3d7aabfaf 100644
--- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
+++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
@@ -30,6 +30,7 @@
#include "ardour/session.h"
#include "ardour/route.h"
+#include "ardour/midi_ui.h"
#include "generic_midi_control_protocol.h"
#include "midicontrollable.h"
@@ -39,8 +40,11 @@ using namespace PBD;
#include "i18n.h"
+#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
+#define ui_bind(x) boost::protect (boost::bind ((x)))
+
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
- : ControlProtocol (s, _("Generic MIDI"))
+ : ControlProtocol (s, _("Generic MIDI"), MidiControlUI::instance())
{
MIDI::Manager* mm = MIDI::Manager::instance();
@@ -59,16 +63,14 @@ GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
_feedback_interval = 10000; // microseconds
last_feedback_time = 0;
- auto_binding = FALSE;
+ /* XXX is it right to do all these in the same thread as whatever emits the signal? */
- Controllable::StartLearning.connect (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1));
- Controllable::StopLearning.connect (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1));
- Controllable::CreateBinding.connect (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3));
- Controllable::DeleteBinding.connect (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1));
+ Controllable::StartLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1));
+ Controllable::StopLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1));
+ Controllable::CreateBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3));
+ Controllable::DeleteBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1));
- Session::SendFeedback.connect (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this));
- Session::AutoBindingOn.connect (*this, boost::bind (&GenericMidiControlProtocol::auto_binding_on, this));
- Session::AutoBindingOff.connect (*this, boost::bind (&GenericMidiControlProtocol::auto_binding_off, this));
+ Session::SendFeedback.connect (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
}
GenericMidiControlProtocol::~GenericMidiControlProtocol ()
@@ -177,7 +179,7 @@ GenericMidiControlProtocol::start_learning (Controllable* c)
MIDIPendingControllable* element = new MIDIPendingControllable;
element->first = mc;
- c->LearningFinished.connect (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc));
+ c->LearningFinished.connect_same_thread (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc));
pending_controllables.push_back (element);
}
@@ -289,18 +291,6 @@ GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos,
}
}
-void
-GenericMidiControlProtocol::auto_binding_on()
-{
- auto_binding = TRUE;
-}
-
-void
-GenericMidiControlProtocol::auto_binding_off()
-{
- auto_binding = FALSE;
-}
-
XMLNode&
GenericMidiControlProtocol::get_state ()
{
@@ -345,46 +335,43 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
_feedback_interval = 10000;
}
- if ( !auto_binding ) {
-
- boost::shared_ptr<Controllable> c;
-
- {
- Glib::Mutex::Lock lm (pending_lock);
- for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
- delete *i;
- }
- pending_controllables.clear ();
- }
-
- Glib::Mutex::Lock lm2 (controllables_lock);
- controllables.clear ();
- nlist = node.children(); // "controls"
-
- if (nlist.empty()) {
- return 0;
+ boost::shared_ptr<Controllable> c;
+
+ {
+ Glib::Mutex::Lock lm (pending_lock);
+ for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
+ delete *i;
}
+ pending_controllables.clear ();
+ }
+
+ Glib::Mutex::Lock lm2 (controllables_lock);
+ controllables.clear ();
+ nlist = node.children(); // "controls"
+
+ if (nlist.empty()) {
+ return 0;
+ }
+
+ nlist = nlist.front()->children ();
- nlist = nlist.front()->children ();
+ for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+ if ((prop = (*niter)->property ("id")) != 0) {
- if ((prop = (*niter)->property ("id")) != 0) {
-
- ID id = prop->value ();
- c = session->controllable_by_id (id);
-
- if (c) {
- MIDIControllable* mc = new MIDIControllable (*_port, *c);
- if (mc->set_state (**niter, version) == 0) {
- controllables.insert (mc);
- }
-
- } else {
- warning << string_compose (
- _("Generic MIDI control: controllable %1 not found in session (ignored)"),
- id) << endmsg;
+ ID id = prop->value ();
+ c = session->controllable_by_id (id);
+
+ if (c) {
+ MIDIControllable* mc = new MIDIControllable (*_port, *c);
+ if (mc->set_state (**niter, version) == 0) {
+ controllables.insert (mc);
}
+
+ } else {
+ warning << string_compose (
+ _("Generic MIDI control: controllable %1 not found in session (ignored)"),
+ id) << endmsg;
}
}
}
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h
index c42d796e81..39958bcf26 100644
--- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h
+++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h
@@ -44,7 +44,6 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
ARDOUR::microseconds_t last_feedback_time;
bool do_feedback;
- bool auto_binding;
void _send_feedback ();
void send_feedback ();
@@ -64,10 +63,6 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
void create_binding (PBD::Controllable*, int, int);
void delete_binding (PBD::Controllable*);
-
- void auto_binding_on();
- void auto_binding_off();
-
};
#endif /* ardour_generic_midi_control_protocol_h */
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index a1f5abf3b0..d6b4007194 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -19,10 +19,13 @@
#include <cstdio> /* for sprintf, sigh */
#include <climits>
+
#include "pbd/error.h"
#include "pbd/xml++.h"
+
#include "midi++/port.h"
#include "midi++/channel.h"
+
#include "ardour/automation_control.h"
#include "midicontrollable.h"
@@ -111,7 +114,7 @@ void
MIDIControllable::learn_about_external_control ()
{
drop_external_control ();
- _port.input()->any.connect (midi_learn_connection, boost::bind (&MIDIControllable::midi_receiver, this, _1, _2, _3));
+ _port.input()->any.connect_same_thread (midi_learn_connection, boost::bind (&MIDIControllable::midi_receiver, this, _1, _2, _3));
}
void
@@ -285,43 +288,43 @@ MIDIControllable::bind_midi (channel_t chn, eventType ev, MIDI::byte additional)
int chn_i = chn;
switch (ev) {
case MIDI::off:
- p.channel_note_off[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2));
+ p.channel_note_off[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2));
/* if this is a bistate, connect to noteOn as well,
and we'll toggle back and forth between the two.
*/
if (bistate) {
- p.channel_note_on[chn_i].connect (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2));
+ p.channel_note_on[chn_i].connect_same_thread (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2));
}
_control_description = "MIDI control: NoteOff";
break;
case MIDI::on:
- p.channel_note_on[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2));
+ p.channel_note_on[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2));
if (bistate) {
- p.channel_note_off[chn_i].connect (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2));
+ p.channel_note_off[chn_i].connect_same_thread (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2));
}
_control_description = "MIDI control: NoteOn";
break;
case MIDI::controller:
- p.channel_controller[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_controller, this, _1, _2));
+ p.channel_controller[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_controller, this, _1, _2));
snprintf (buf, sizeof (buf), "MIDI control: Controller %d", control_additional);
_control_description = buf;
break;
case MIDI::program:
if (!bistate) {
- p.channel_program_change[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_program_change, this, _1, _2));
+ p.channel_program_change[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_program_change, this, _1, _2));
_control_description = "MIDI control: ProgramChange";
}
break;
case MIDI::pitchbend:
if (!bistate) {
- p.channel_pitchbend[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_pitchbend, this, _1, _2));
+ p.channel_pitchbend[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_pitchbend, this, _1, _2));
_control_description = "MIDI control: Pitchbend";
}
break;
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 9f4ffb10c0..48d074e117 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -43,6 +43,7 @@
#include "ardour/dB.h"
#include "ardour/debug.h"
#include "ardour/location.h"
+#include "ardour/midi_ui.h"
#include "ardour/panner.h"
#include "ardour/route.h"
#include "ardour/session.h"
@@ -71,8 +72,11 @@ using boost::shared_ptr;
MackieMidiBuilder builder;
+#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
+#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
+
MackieControlProtocol::MackieControlProtocol (Session& session)
- : ControlProtocol (session, X_("Mackie"))
+ : ControlProtocol (session, X_("Mackie"), MidiControlUI::instance())
, _current_initial_bank (0)
, _surface (0)
, _jog_wheel (*this)
@@ -536,23 +540,23 @@ void
MackieControlProtocol::connect_session_signals()
{
// receive routes added
- session->RouteAdded.connect(session_connections, boost::bind (&MackieControlProtocol::notify_route_added, this, _1));
+ session->RouteAdded.connect(session_connections, ui_bind (&MackieControlProtocol::notify_route_added, this, _1), midi_ui_context());
// receive record state toggled
- session->RecordStateChanged.connect(session_connections, boost::bind (&MackieControlProtocol::notify_record_state_changed, this));
+ session->RecordStateChanged.connect(session_connections, ui_bind (&MackieControlProtocol::notify_record_state_changed, this), midi_ui_context());
// receive transport state changed
- session->TransportStateChange.connect(session_connections, boost::bind (&MackieControlProtocol::notify_transport_state_changed, this));
+ session->TransportStateChange.connect(session_connections, ui_bind (&MackieControlProtocol::notify_transport_state_changed, this), midi_ui_context());
// receive punch-in and punch-out
- Config->ParameterChanged.connect(session_connections, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1));
- session->config.ParameterChanged.connect (session_connections, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1));
+ Config->ParameterChanged.connect(session_connections, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), midi_ui_context());
+ session->config.ParameterChanged.connect (session_connections, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), midi_ui_context());
// receive rude solo changed
- session->SoloActive.connect(session_connections, boost::bind (&MackieControlProtocol::notify_solo_active_changed, this, _1));
+ session->SoloActive.connect(session_connections, ui_bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), midi_ui_context());
// make sure remote id changed signals reach here
// see also notify_route_added
Sorted sorted = get_sorted_routes();
for (Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it) {
- ((*it)->RemoteControlIDChanged.connect (route_connections, boost::bind(&MackieControlProtocol::notify_remote_id_changed, this)));
+ (*it)->RemoteControlIDChanged.connect (route_connections, ui_bind(&MackieControlProtocol::notify_remote_id_changed, this), midi_ui_context());
}
}
@@ -569,9 +573,9 @@ MackieControlProtocol::add_port (MIDI::Port & midi_port, int number)
MackiePort * sport = new MackiePort (*this, midi_port, number);
_ports.push_back (sport);
- sport->init_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_init, this, sport));
- sport->active_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_active, this, sport));
- sport->inactive_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_inactive, this, sport));
+ sport->init_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_init, this, sport));
+ sport->active_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_active, this, sport));
+ sport->inactive_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_inactive, this, sport));
}
}
@@ -652,7 +656,7 @@ MackieControlProtocol::initialize_surface()
// Connect events. Must be after route table otherwise there will be trouble
for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) {
- (*it)->control_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3));
+ (*it)->control_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3));
}
}
@@ -1409,7 +1413,7 @@ MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl)
typedef ARDOUR::RouteList ARS;
for (ARS::iterator it = rl.begin(); it != rl.end(); ++it) {
- (*it)->RemoteControlIDChanged.connect (route_connections, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this));
+ (*it)->RemoteControlIDChanged.connect (route_connections, ui_bind (&MackieControlProtocol::notify_remote_id_changed, this), midi_ui_context());
}
}
diff --git a/libs/surfaces/mackie/mackie_port.cc b/libs/surfaces/mackie/mackie_port.cc
index 069ad9abb4..476e6acb81 100644
--- a/libs/surfaces/mackie/mackie_port.cc
+++ b/libs/surfaces/mackie/mackie_port.cc
@@ -90,7 +90,7 @@ void MackiePort::open()
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackiePort::open %1\n", *this));
- port().input()->sysex.connect (sysex_connection, boost::bind (&MackiePort::handle_midi_sysex, this, _1, _2, _3));
+ port().input()->sysex.connect_same_thread (sysex_connection, boost::bind (&MackiePort::handle_midi_sysex, this, _1, _2, _3));
// make sure the device is connected
init();
@@ -272,7 +272,7 @@ void MackiePort::finalise_init( bool yn )
void MackiePort::connect_any()
{
if (!any_connection.connected()) {
- port().input()->any.connect (any_connection, boost::bind (&MackiePort::handle_midi_any, this, _1, _2, _3));
+ port().input()->any.connect_same_thread (any_connection, boost::bind (&MackiePort::handle_midi_any, this, _1, _2, _3));
}
}
diff --git a/libs/surfaces/mackie/route_signal.cc b/libs/surfaces/mackie/route_signal.cc
index 9a3dd41bf4..6dc8532db9 100644
--- a/libs/surfaces/mackie/route_signal.cc
+++ b/libs/surfaces/mackie/route_signal.cc
@@ -19,6 +19,7 @@
#include "ardour/route.h"
#include "ardour/track.h"
+#include "ardour/midi_ui.h"
#include "ardour/panner.h"
#include "mackie_control_protocol.h"
@@ -29,38 +30,41 @@ using namespace ARDOUR;
using namespace Mackie;
using namespace std;
+#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
+#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
+
void RouteSignal::connect()
{
if (_strip.has_solo()) {
- _route->solo_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this));
+ _route->solo_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this), midi_ui_context());
}
if (_strip.has_mute()) {
- _route->mute_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this));
+ _route->mute_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this), midi_ui_context());
}
if (_strip.has_gain()) {
- _route->gain_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false));
+ _route->gain_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false), midi_ui_context());
}
- _route->NameChanged.connect (connections, boost::bind (&MackieControlProtocol::notify_name_changed, &_mcp, this));
+ _route->NameChanged.connect (connections, ui_bind (&MackieControlProtocol::notify_name_changed, &_mcp, this), midi_ui_context());
if (_route->panner()) {
- _route->panner()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false));
+ _route->panner()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context());
for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) {
- _route->panner()->streampanner(i).Changed.connect (connections, boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false));
+ _route->panner()->streampanner(i).Changed.connect (connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context());
}
}
boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
if (trk) {
- trk->rec_enable_control()->Changed .connect(connections, boost::bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this));
+ trk->rec_enable_control()->Changed .connect(connections, ui_bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this), midi_ui_context());
}
// 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 (connections, boost::bind (&MackieControlProtocol::notify_active_changed, &_mcp, this));
+ _route->active_changed.connect (connections, ui_bind (&MackieControlProtocol::notify_active_changed, &_mcp, this), midi_ui_context());
// TODO
// SelectedChanged
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc
index a076b161e7..6054d01334 100644
--- a/libs/surfaces/osc/osc.cc
+++ b/libs/surfaces/osc/osc.cc
@@ -51,9 +51,12 @@ using namespace ARDOUR;
using namespace std;
using namespace Glib;
-
#include "pbd/abstract_ui.cc" // instantiate template
+#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
+
+OSC* OSC::_instance = 0;
+
#ifdef DEBUG
static void error_callback(int num, const char *m, const char *path)
{
@@ -67,10 +70,11 @@ static void error_callback(int, const char *, const char *)
#endif
OSC::OSC (Session& s, uint32_t port)
- : ControlProtocol (s, "OSC")
+ : ControlProtocol (s, "OSC", this)
, AbstractUI<OSCUIRequest> ("osc")
, _port(port)
{
+ _instance = this;
_shutdown = false;
_osc_server = 0;
_osc_unix_server = 0;
@@ -83,12 +87,13 @@ OSC::OSC (Session& s, uint32_t port)
// "Application Hooks"
session_loaded (s);
- session->Exported.connect (*this, boost::bind (&OSC::session_exported, this, _1, _2));
+ session->Exported.connect (*this, ui_bind (&OSC::session_exported, this, _1, _2), this);
}
OSC::~OSC()
{
stop ();
+ _instance = 0;
}
void
@@ -573,7 +578,7 @@ OSC::listen_to_route (boost::shared_ptr<Route> route, lo_address addr)
*/
if (!route_exists) {
- route->GoingAway.connect (*this, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Route> (route)));
+ route->GoingAway.connect (*this, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Route> (route)), this);
}
}
diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h
index 15914bfbbd..0c72671ae9 100644
--- a/libs/surfaces/osc/osc.h
+++ b/libs/surfaces/osc/osc.h
@@ -60,6 +60,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
OSC (ARDOUR::Session&, uint32_t port);
virtual ~OSC();
+ static OSC* instance() { return _instance; }
+
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
@@ -182,8 +184,10 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
void drop_route (boost::weak_ptr<ARDOUR::Route>);
typedef std::list<OSCControllable*> Controllables;
-
+
Controllables controllables;
+
+ static OSC* _instance;
};
#endif // ardour_osc_h
diff --git a/libs/surfaces/osc/osc_controllable.cc b/libs/surfaces/osc/osc_controllable.cc
index f5deadd41d..baf888667e 100644
--- a/libs/surfaces/osc/osc_controllable.cc
+++ b/libs/surfaces/osc/osc_controllable.cc
@@ -24,6 +24,7 @@
#include "ardour/route.h"
+#include "osc.h"
#include "osc_controllable.h"
using namespace sigc;
@@ -35,7 +36,7 @@ OSCControllable::OSCControllable (lo_address a, const std::string& p, boost::sha
, addr (a)
, path (p)
{
- c->Changed.connect (changed_connection, mem_fun (*this, &OSCControllable::send_change));
+ c->Changed.connect (changed_connection, boost::bind (&OSCControllable::send_change, this), OSC::instance());
}
OSCControllable::~OSCControllable ()
diff --git a/libs/surfaces/osc/osc_controllable.h b/libs/surfaces/osc/osc_controllable.h
index 67b8284460..55e2815d35 100644
--- a/libs/surfaces/osc/osc_controllable.h
+++ b/libs/surfaces/osc/osc_controllable.h
@@ -30,9 +30,7 @@
#include "ardour/types.h"
namespace ARDOUR {
-
-class Route;
-
+ class Route;
}
class OSCControllable : public PBD::Stateful
diff --git a/libs/surfaces/powermate/powermate.cc b/libs/surfaces/powermate/powermate.cc
index 31154ad879..a3b535c9e0 100644
--- a/libs/surfaces/powermate/powermate.cc
+++ b/libs/surfaces/powermate/powermate.cc
@@ -89,7 +89,7 @@ int find_powermate(int mode)
}
PowermateControlProtocol::PowermateControlProtocol (Session& s)
- : ControlProtocol (s, "powermate")
+ : ControlProtocol (s, "powermate", 0 /* XXX need an event loop here */)
{
}