13
0

OSC: try to prevent race when clearing devices

This commit is contained in:
Len Ovens 2017-06-30 20:13:18 -07:00
parent 41bc5bc116
commit 296c9ae03e
4 changed files with 24 additions and 14 deletions

View File

@ -332,6 +332,7 @@ OSC::stop ()
periodic_connection.disconnect (); periodic_connection.disconnect ();
session_connections.drop_connections (); session_connections.drop_connections ();
cueobserver_connections.drop_connections (); cueobserver_connections.drop_connections ();
Glib::Threads::Mutex::Lock lm (surfaces_lock);
// Delete any active route observers // Delete any active route observers
for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
@ -1343,6 +1344,8 @@ OSC::refresh_surface (lo_message msg)
void void
OSC::clear_devices () OSC::clear_devices ()
{ {
tick = false;
Glib::Threads::Mutex::Lock lm (surfaces_lock);
for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
OSCRouteObserver* rc; OSCRouteObserver* rc;
@ -1389,6 +1392,7 @@ OSC::clear_devices ()
// clear out surfaces // clear out surfaces
_surface.clear(); _surface.clear();
tick = true;
} }
int int
@ -1577,8 +1581,7 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui
s->send_page_size = se_size; s->send_page_size = se_size;
s->plug_page_size = pi_size; s->plug_page_size = pi_size;
// set bank and strip feedback // set bank and strip feedback
// set_bank(s->bank, msg); set_bank(s->bank, msg);
recalcbanks ();
global_feedback (s->feedback, get_address (msg), s->gainmode); global_feedback (s->feedback, get_address (msg), s->gainmode);
sel_send_pagesize (se_size, msg); sel_send_pagesize (se_size, msg);
@ -1661,10 +1664,13 @@ OSC::get_surface (lo_address addr)
rurl = lo_address_get_url (addr); rurl = lo_address_get_url (addr);
r_url = rurl; r_url = rurl;
free (rurl); free (rurl);
for (uint32_t it = 0; it < _surface.size(); ++it) { {
//find setup for this server Glib::Threads::Mutex::Lock lm (surfaces_lock);
if (!_surface[it].remote_url.find(r_url)){ for (uint32_t it = 0; it < _surface.size(); ++it) {
return &_surface[it]; //find setup for this server
if (!_surface[it].remote_url.find(r_url)){
return &_surface[it];
}
} }
} }
@ -1691,15 +1697,17 @@ OSC::get_surface (lo_address addr)
s.plugin_id = 1; s.plugin_id = 1;
s.nstrips = s.strips.size(); s.nstrips = s.strips.size();
_surface.push_back (s); {
Glib::Threads::Mutex::Lock lm (surfaces_lock);
_surface.push_back (s);
}
// moved this down here as selection may need s.<anything to do with select> set // moved this down here as selection may need s.<anything to do with select> set
if (!_select || (_select != ControlProtocol::first_selected_stripable())) { if (!_select || (_select != ControlProtocol::first_selected_stripable())) {
gui_selection_changed(); gui_selection_changed();
} }
// set bank and strip feedback // set bank and strip feedback
//_set_bank(s.bank, addr); _set_bank(s.bank, addr);
recalcbanks ();
// Set global/master feedback // Set global/master feedback
global_feedback (s.feedback, addr, s.gainmode); global_feedback (s.feedback, addr, s.gainmode);
@ -3580,7 +3588,7 @@ OSC::sel_sendgain (int id, float val, lo_message msg)
s = _select; s = _select;
} }
float abs; float abs;
int send_id; int send_id = 0;
if (s) { if (s) {
if (id > 0) { if (id > 0) {
send_id = id - 1; send_id = id - 1;
@ -3619,7 +3627,7 @@ OSC::sel_sendfader (int id, float val, lo_message msg)
s = _select; s = _select;
} }
float abs; float abs;
int send_id; int send_id = 0;
if (s) { if (s) {
if (id > 0) { if (id > 0) {
@ -3693,7 +3701,7 @@ OSC::sel_sendenable (int id, float val, lo_message msg)
} else { } else {
s = _select; s = _select;
} }
int send_id; int send_id = 0;
if (s) { if (s) {
if (id > 0) { if (id > 0) {
send_id = id - 1; send_id = id - 1;
@ -4598,6 +4606,7 @@ OSC::periodic (void)
if (!tick) { if (!tick) {
Glib::usleep(100); // let flurry of signals subside Glib::usleep(100); // let flurry of signals subside
if (global_init) { if (global_init) {
Glib::Threads::Mutex::Lock lm (surfaces_lock);
for (uint32_t it = 0; it < _surface.size(); it++) { for (uint32_t it = 0; it < _surface.size(); it++) {
OSCSurface* sur = &_surface[it]; OSCSurface* sur = &_surface[it];
lo_address addr = lo_address_new_from_url (sur->remote_url.c_str()); lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());

View File

@ -163,6 +163,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
// storage for each surface's settings // storage for each surface's settings
mutable Glib::Threads::Mutex surfaces_lock;
typedef std::vector<OSCSurface> Surface; typedef std::vector<OSCSurface> Surface;
Surface _surface; Surface _surface;

View File

@ -392,7 +392,7 @@ OSCRouteObserver::gain_automation (string path)
send_gain_message (path, control); send_gain_message (path, control);
as = control->alist()->automation_state(); as = control->alist()->automation_state();
string auto_name; string auto_name;
float output; float output = 0;
switch (as) { switch (as) {
case ARDOUR::Off: case ARDOUR::Off:
output = 0; output = 0;

View File

@ -660,7 +660,7 @@ OSCSelectObserver::gain_message ()
void void
OSCSelectObserver::gain_automation () OSCSelectObserver::gain_automation ()
{ {
float output; float output = 0;
as = _strip->gain_control()->alist()->automation_state(); as = _strip->gain_control()->alist()->automation_state();
string auto_name; string auto_name;
switch (as) { switch (as) {