summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-05-07 13:35:57 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-07 13:36:04 -0400
commit672528baf4bbe0f63463502d336f29164c259cc8 (patch)
treef568d52e65e7a752211f43e7806e6002565a2ebc
parenta232673454fa3583da22fdd55eea16200f90c438 (diff)
fix shared_ptr<Route> management in Mackie support so that deleted routes are destroyed
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc26
-rw-r--r--libs/surfaces/mackie/mcp_buttons.cc9
-rw-r--r--libs/surfaces/mackie/strip.cc1
-rw-r--r--libs/surfaces/mackie/surface.cc3
4 files changed, 23 insertions, 16 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 1ee5d95e07..df46464334 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -394,7 +394,9 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
uint32_t strip_cnt = n_strips (false); // do not include locked strips
// in this count
- if (initial >= sorted.size()) {
+ if (initial >= sorted.size() && !force) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank target %1 exceeds route range %2\n",
+ _current_initial_bank, sorted.size()));
/* too high, we can't get there */
return -1;
}
@@ -403,6 +405,8 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
/* no banking - not enough routes to fill all strips and we're
* not at the first one.
*/
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("less routes (%1) than strips (%2) and we're at the end already (%3)\n",
+ sorted.size(), strip_cnt, _current_initial_bank));
return -1;
}
@@ -437,6 +441,14 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
}
} else {
+ /* all strips need to be reset */
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("clear all strips, bank target %1 is outside route range %2\n",
+ _current_initial_bank, sorted.size()));
+ for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
+ vector<boost::shared_ptr<Route> > routes;
+ /* pass in an empty route list, so that all strips will be reset */
+ (*si)->map_routes (routes);
+ }
return -1;
}
@@ -1743,8 +1755,6 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
set_flip_mode (Normal);
}
- boost::shared_ptr<Route> old_route = _subview_route;
-
if (!subview_mode_would_be_ok (sm, r)) {
if (r) {
@@ -1787,14 +1797,12 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
return -1;
}
- _subview_mode = sm;
+ boost::shared_ptr<Route> old_route = _subview_route;
- if (r) {
- /* retain _subview_route even if it is reset to null implicitly */
- _subview_route = r;
- }
+ _subview_mode = sm;
+ _subview_route = r;
- if (r != old_route) {
+ if (_subview_route != old_route) {
subview_route_connections.drop_connections ();
/* Catch the current subview route going away */
diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc
index 5678bdfe12..1869d5e231 100644
--- a/libs/surfaces/mackie/mcp_buttons.cc
+++ b/libs/surfaces/mackie/mcp_buttons.cc
@@ -726,8 +726,7 @@ MackieControlProtocol::plugin_release (Button &)
LedState
MackieControlProtocol::eq_press (Button &)
{
- boost::shared_ptr<Route> r = first_selected_route ();
- set_subview_mode (EQ, r);
+ set_subview_mode (EQ, first_selected_route ());
return none; /* led state handled by set_subview_mode() */
}
@@ -739,8 +738,7 @@ MackieControlProtocol::eq_release (Button &)
LedState
MackieControlProtocol::dyn_press (Button &)
{
- boost::shared_ptr<Route> r = first_selected_route ();
- set_subview_mode (Dynamics, r);
+ set_subview_mode (Dynamics, first_selected_route ());
return none; /* led state handled by set_subview_mode() */
}
@@ -922,8 +920,7 @@ MackieControlProtocol::track_release (Mackie::Button&)
Mackie::LedState
MackieControlProtocol::send_press (Mackie::Button&)
{
- boost::shared_ptr<Route> r = first_selected_route ();
- set_subview_mode (Sends, r);
+ set_subview_mode (Sends, first_selected_route());
return none; /* led state handled by set_subview_mode() */
}
Mackie::LedState
diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc
index e71c9a6798..7de5f74701 100644
--- a/libs/surfaces/mackie/strip.cc
+++ b/libs/surfaces/mackie/strip.cc
@@ -185,6 +185,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool /*with_messages*/)
reset_saved_values ();
if (!r) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 Strip %2 mapped to null route\n", _surface->number(), _index));
zero ();
return;
}
diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc
index 6941c68d29..24e82d59b5 100644
--- a/libs/surfaces/mackie/surface.cc
+++ b/libs/surfaces/mackie/surface.cc
@@ -937,7 +937,7 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes)
vector<boost::shared_ptr<Route> >::const_iterator r;
Strips::iterator s = strips.begin();
- DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 routes\n", routes.size()));
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 routes to %2 strips\n", routes.size(), strips.size()));
for (r = routes.begin(); r != routes.end() && s != strips.end(); ++s) {
@@ -953,6 +953,7 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes)
}
for (; s != strips.end(); ++s) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 being set to null route\n", (*s)->index()));
(*s)->set_route (boost::shared_ptr<Route>());
}
}