Mackie Control: Be consistent and take the surfaces lock when iterating.
Some places in the code take the lock, others don't. This makes everyone take the lock.
This commit is contained in:
parent
a84543bcc7
commit
c1dddb1b25
@ -210,10 +210,13 @@ MackieControlProtocol::ping_devices ()
|
||||
* malfunction if it is.
|
||||
*/
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
(*si)->connected ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go to the previous track.
|
||||
void
|
||||
@ -237,11 +240,14 @@ MackieControlProtocol::next_track()
|
||||
bool
|
||||
MackieControlProtocol::stripable_is_locked_to_strip (boost::shared_ptr<Stripable> r) const
|
||||
{
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
if ((*si)->stripable_is_locked_to_strip (r)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -361,9 +367,12 @@ MackieControlProtocol::n_strips (bool with_locked_strips) const
|
||||
{
|
||||
uint32_t strip_count = 0;
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
strip_count += (*si)->n_strips (with_locked_strips);
|
||||
}
|
||||
}
|
||||
|
||||
return strip_count;
|
||||
}
|
||||
@ -413,6 +422,8 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
|
||||
Sorted::iterator r = sorted.begin() + _current_initial_bank;
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
vector<boost::shared_ptr<Stripable> > stripables;
|
||||
uint32_t added = 0;
|
||||
@ -427,16 +438,20 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
|
||||
(*si)->map_stripables (stripables);
|
||||
}
|
||||
}
|
||||
|
||||
} 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()));
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
vector<boost::shared_ptr<Stripable> > stripables;
|
||||
/* pass in an empty stripables list, so that all strips will be reset */
|
||||
(*si)->map_stripables (stripables);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -660,9 +675,12 @@ MackieControlProtocol::device_ready ()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("device ready init (active=%1)\n", active()));
|
||||
// Clear the surface so that any left over control from other programs are reset.
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
|
||||
(*s)->zero_all ();
|
||||
}
|
||||
}
|
||||
update_surfaces ();
|
||||
set_subview_mode (Mackie::Subview::None, boost::shared_ptr<Stripable>());
|
||||
set_flip_mode (Normal);
|
||||
@ -2308,15 +2326,20 @@ void
|
||||
MackieControlProtocol::stripable_selection_changed ()
|
||||
{
|
||||
//this function is called after the stripable selection is "stable", so this is the place to check surface selection state
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
(*si)->update_strip_selection ();
|
||||
}
|
||||
}
|
||||
|
||||
/* if we are following the Gui, find the selected strips and map them here */
|
||||
if (_device_info.single_fader_follows_selection()) {
|
||||
|
||||
Sorted sorted = get_sorted_stripables();
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
Sorted::iterator r = sorted.begin();
|
||||
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
vector<boost::shared_ptr<Stripable> > stripables;
|
||||
@ -2330,6 +2353,7 @@ MackieControlProtocol::stripable_selection_changed ()
|
||||
|
||||
(*si)->map_stripables (stripables);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user