OSC link: Clean up link not ready and surface refresh

This commit is contained in:
Len Ovens 2017-11-07 09:31:14 -08:00
parent bb8d65c528
commit ba383b4726
4 changed files with 86 additions and 49 deletions

View file

@ -1406,15 +1406,16 @@ OSC::parse_link (const char *path, const char* types, lo_arg **argv, int argc, l
} else { } else {
// User expects this surface to be removed from any sets // User expects this surface to be removed from any sets
int oldset = sur->linkset; uint32_t oldset = sur->linkset;
if (oldset) { if (oldset) {
int oldid = sur->linkid; uint32_t oldid = sur->linkid;
sur->linkid = 1; sur->linkid = 1;
sur->linkset = 0; sur->linkset = 0;
ls = &link_sets[oldid]; ls = &link_sets[oldset];
if (ls) { if (ls) {
ls->not_ready = 1; ls->not_ready = oldid;
ls->urls[(uint32_t) data] = ""; ls->urls[oldid] = "";
surface_link_state (ls);
} }
} }
return 0; return 0;
@ -1440,7 +1441,7 @@ OSC::parse_link (const char *path, const char* types, lo_arg **argv, int argc, l
ls->urls[(uint32_t) data] = sur->remote_url; ls->urls[(uint32_t) data] = sur->remote_url;
ls->not_ready = link_check (set); ls->not_ready = link_check (set);
if (ls->not_ready) { if (ls->not_ready) {
strip_feedback (sur, true); surface_link_state (ls);
} else { } else {
_set_bank (1, get_address (msg)); _set_bank (1, get_address (msg));
} }
@ -1450,6 +1451,22 @@ OSC::parse_link (const char *path, const char* types, lo_arg **argv, int argc, l
return ret; return ret;
} }
void
OSC::surface_link_state (LinkSet * set)
{
for (uint32_t dv = 1; dv < set->urls.size(); dv++) {
OSCSurface *sur;
if (set->urls[dv] != "") {
string url = set->urls[dv];
sur = get_surface (lo_address_new_from_url (url.c_str()));
for (uint32_t i = 0; i < sur->observers.size(); i++) {
sur->observers[i]->set_link_ready (set->not_ready);
}
}
}
}
int int
OSC::link_check (uint32_t set) OSC::link_check (uint32_t set)
{ {
@ -1862,7 +1879,6 @@ OSC::global_feedback (OSCSurface* sur)
void void
OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
{ {
new_bank_size = true;
sur->strips = get_sorted_stripables(sur->strip_types, sur->cue); sur->strips = get_sorted_stripables(sur->strip_types, sur->cue);
sur->nstrips = sur->strips.size(); sur->nstrips = sur->strips.size();
if (new_bank_size || (!sur->feedback[0] && !sur->feedback[1])) { if (new_bank_size || (!sur->feedback[0] && !sur->feedback[1])) {
@ -1889,7 +1905,8 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
} else { } else {
if (sur->feedback[0] || sur->feedback[1]) { if (sur->feedback[0] || sur->feedback[1]) {
for (uint32_t i = 0; i < sur->observers.size(); i++) { for (uint32_t i = 0; i < sur->observers.size(); i++) {
sur->observers[i]->refresh_strip(true); boost::shared_ptr<ARDOUR::Stripable> str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str()));
sur->observers[i]->refresh_strip(str, true);
} }
} }
} }
@ -2023,6 +2040,10 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
bank_leds (sur); bank_leds (sur);
lo_address_free (sur_addr); lo_address_free (sur_addr);
} }
if (not_ready) {
surface_link_state (set);
}
} else { } else {
s->bank = bank_limits_check (bank_start, s->bank_size, nstrips); s->bank = bank_limits_check (bank_start, s->bank_size, nstrips);

View file

@ -277,6 +277,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr); boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr);
void global_feedback (OSCSurface* sur); void global_feedback (OSCSurface* sur);
void strip_feedback (OSCSurface* sur, bool new_bank_size); void strip_feedback (OSCSurface* sur, bool new_bank_size);
void surface_link_state (LinkSet * sur);
void surface_destroy (OSCSurface* sur); void surface_destroy (OSCSurface* sur);
uint32_t bank_limits_check (uint32_t bank, uint32_t size, uint32_t total); uint32_t bank_limits_check (uint32_t bank, uint32_t size, uint32_t total);
void bank_leds (OSCSurface* sur); void bank_leds (OSCSurface* sur);

View file

@ -53,12 +53,26 @@ OSCRouteObserver::OSCRouteObserver (OSC& o, uint32_t ss, ArdourSurface::OSC::OSC
gainmode = sur->gainmode; gainmode = sur->gainmode;
feedback = sur->feedback; feedback = sur->feedback;
in_line = feedback[2]; in_line = feedback[2];
uint32_t sid = sur->bank + ssid - 2;
uint32_t not_ready = 0;
if (sur->linkset) {
not_ready = _osc.link_sets[sur->linkset].not_ready;
}
if (not_ready) {
set_link_ready (not_ready);
} else if (sid >= sur->strips.size ()) {
// this _should_ only occure if the number of strips is less than banksize
_strip = boost::shared_ptr<ARDOUR::Stripable>();
clear_strip ();
} else {
_strip = sur->strips[sid];
refresh_strip (_strip, true);
}
if (sur->expand_enable) { if (sur->expand_enable) {
set_expand (sur->expand); set_expand (sur->expand);
} else { } else {
set_expand (0); set_expand (0);
} }
refresh_strip (true);
} }
OSCRouteObserver::~OSCRouteObserver () OSCRouteObserver::~OSCRouteObserver ()
@ -85,7 +99,7 @@ OSCRouteObserver::no_strip ()
} }
void void
OSCRouteObserver::refresh_strip (bool force) OSCRouteObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, bool force)
{ {
_init = true; _init = true;
if (_tick_busy) { if (_tick_busy) {
@ -93,51 +107,22 @@ OSCRouteObserver::refresh_strip (bool force)
} }
_last_gain =-1.0; _last_gain =-1.0;
_last_trim =-1.0; _last_trim =-1.0;
uint32_t sid = sur->bank + ssid - 2;
if (sid >= sur->strips.size ()) {
// this _should_ only occure if the number of strips is less than banksize
if (_strip) {
_strip = boost::shared_ptr<ARDOUR::Stripable>();
clear_strip ();
}
return;
}
if (sur->linkset) {
uint32_t not_ready = _osc.link_sets[sur->linkset].not_ready;
if (not_ready) {
clear_strip ();
switch (ssid) {
case 1:
_osc.text_message_with_id ("/strip/name", ssid, "Device", in_line, addr);
break;
case 2:
_osc.text_message_with_id ("/strip/name", ssid, string_compose ("%1", not_ready), in_line, addr);
break;
case 3:
_osc.text_message_with_id ("/strip/name", ssid, "Missing", in_line, addr);
break;
case 4:
_osc.text_message_with_id ("/strip/name", ssid, "from", in_line, addr);
break;
case 5:
_osc.text_message_with_id ("/strip/name", ssid, "Linkset", in_line, addr);
break;
default:
break;
}
return;
}
}
send_select_status (ARDOUR::Properties::selected); send_select_status (ARDOUR::Properties::selected);
boost::shared_ptr<ARDOUR::Stripable> new_strip = sur->strips[sur->bank + ssid - 2]; if ((new_strip == _strip) && !force) {
if (_strip && (new_strip == _strip) && !force) { // no change don't send feedback
_init = false; _init = false;
return; return;
} }
strip_connections.drop_connections (); strip_connections.drop_connections ();
_strip = new_strip; _strip = new_strip;
if (!_strip) {
// this strip is blank and should be cleared
clear_strip ();
_init = false;
return;
}
_strip->DropReferences.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::no_strip, this), OSC::instance()); _strip->DropReferences.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::no_strip, this), OSC::instance());
as = ARDOUR::Off; as = ARDOUR::Off;
@ -217,6 +202,35 @@ OSCRouteObserver::set_expand (uint32_t expand)
} }
} }
void
OSCRouteObserver::set_link_ready (uint32_t not_ready)
{
if (not_ready) {
clear_strip ();
switch (ssid) {
case 1:
_osc.text_message_with_id ("/strip/name", ssid, "Device", in_line, addr);
break;
case 2:
_osc.text_message_with_id ("/strip/name", ssid, string_compose ("%1", not_ready), in_line, addr);
break;
case 3:
_osc.text_message_with_id ("/strip/name", ssid, "Missing", in_line, addr);
break;
case 4:
_osc.text_message_with_id ("/strip/name", ssid, "from", in_line, addr);
break;
case 5:
_osc.text_message_with_id ("/strip/name", ssid, "Linkset", in_line, addr);
break;
default:
break;
}
} else {
refresh_strip (_strip, true);
}
}
void void
OSCRouteObserver::clear_strip () OSCRouteObserver::clear_strip ()
{ {

View file

@ -44,8 +44,9 @@ class OSCRouteObserver
lo_address address () const { return addr; }; lo_address address () const { return addr; };
void tick (void); void tick (void);
void send_select_status (const PBD::PropertyChange&); void send_select_status (const PBD::PropertyChange&);
void refresh_strip (bool force); void refresh_strip (boost::shared_ptr<ARDOUR::Stripable> strip, bool force);
void set_expand (uint32_t expand); void set_expand (uint32_t expand);
void set_link_ready (uint32_t not_ready);
void clear_strip (); void clear_strip ();
private: private: