mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Replace control list locks with RWLocks
towards fixing #6238 and #6096. GUI thread: #2 Glib::Threads::Mutex::Lock::Lock #3 Evoral::ControlList::eval #4 Evoral::Control::get_double #5 ARDOUR::AutomationControl::get_value #6 ProcessorEntry::Control::control_changed .. #15 PBD::Timer::timeout_handler at the same time: Audio Thread (try-lock, fails) #0 Evoral::Curve::rt_safe_get_vector #1 ARDOUR::Amp::setup_gain_automation #2 ARDOUR::Route::process_output_buffers Due to the failed try-lock.. AMP::_apply_gain_automation is false. and Amp::run() uses a different gain factor. -> click.
This commit is contained in:
parent
9391da0c24
commit
96ce9c304e
3 changed files with 32 additions and 32 deletions
|
|
@ -109,7 +109,7 @@ public:
|
||||||
|
|
||||||
EventList::size_type size() const { return _events.size(); }
|
EventList::size_type size() const { return _events.size(); }
|
||||||
double length() const {
|
double length() const {
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::ReaderLock lm (_lock);
|
||||||
return _events.empty() ? 0.0 : _events.back()->when;
|
return _events.empty() ? 0.0 : _events.back()->when;
|
||||||
}
|
}
|
||||||
bool empty() const { return _events.empty(); }
|
bool empty() const { return _events.empty(); }
|
||||||
|
|
@ -184,18 +184,18 @@ public:
|
||||||
std::pair<ControlList::iterator,ControlList::iterator> control_points_adjacent (double when);
|
std::pair<ControlList::iterator,ControlList::iterator> control_points_adjacent (double when);
|
||||||
|
|
||||||
template<class T> void apply_to_points (T& obj, void (T::*method)(const ControlList&)) {
|
template<class T> void apply_to_points (T& obj, void (T::*method)(const ControlList&)) {
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
(obj.*method)(*this);
|
(obj.*method)(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
double eval (double where) {
|
double eval (double where) {
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::ReaderLock lm (_lock);
|
||||||
return unlocked_eval (where);
|
return unlocked_eval (where);
|
||||||
}
|
}
|
||||||
|
|
||||||
double rt_safe_eval (double where, bool& ok) {
|
double rt_safe_eval (double where, bool& ok) {
|
||||||
|
|
||||||
Glib::Threads::Mutex::Lock lm (_lock, Glib::Threads::TRY_LOCK);
|
Glib::Threads::RWLock::ReaderLock lm (_lock, Glib::Threads::TRY_LOCK);
|
||||||
|
|
||||||
if ((ok = lm.locked())) {
|
if ((ok = lm.locked())) {
|
||||||
return unlocked_eval (where);
|
return unlocked_eval (where);
|
||||||
|
|
@ -226,7 +226,7 @@ public:
|
||||||
double default_value() const { return _default_value; }
|
double default_value() const { return _default_value; }
|
||||||
|
|
||||||
// FIXME: const violations for Curve
|
// FIXME: const violations for Curve
|
||||||
Glib::Threads::Mutex& lock() const { return _lock; }
|
Glib::Threads::RWLock& lock() const { return _lock; }
|
||||||
LookupCache& lookup_cache() const { return _lookup_cache; }
|
LookupCache& lookup_cache() const { return _lookup_cache; }
|
||||||
SearchCache& search_cache() const { return _search_cache; }
|
SearchCache& search_cache() const { return _search_cache; }
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ protected:
|
||||||
mutable LookupCache _lookup_cache;
|
mutable LookupCache _lookup_cache;
|
||||||
mutable SearchCache _search_cache;
|
mutable SearchCache _search_cache;
|
||||||
|
|
||||||
mutable Glib::Threads::Mutex _lock;
|
mutable Glib::Threads::RWLock _lock;
|
||||||
|
|
||||||
Parameter _parameter;
|
Parameter _parameter;
|
||||||
ParameterDescriptor _desc;
|
ParameterDescriptor _desc;
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ void
|
||||||
ControlList::copy_events (const ControlList& other)
|
ControlList::copy_events (const ControlList& other)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
_events.clear ();
|
_events.clear ();
|
||||||
for (const_iterator i = other.begin(); i != other.end(); ++i) {
|
for (const_iterator i = other.begin(); i != other.end(); ++i) {
|
||||||
_events.push_back (new ControlEvent ((*i)->when, (*i)->value));
|
_events.push_back (new ControlEvent ((*i)->when, (*i)->value));
|
||||||
|
|
@ -214,7 +214,7 @@ void
|
||||||
ControlList::clear ()
|
ControlList::clear ()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
_events.clear ();
|
_events.clear ();
|
||||||
unlocked_invalidate_insert_iterator ();
|
unlocked_invalidate_insert_iterator ();
|
||||||
mark_dirty ();
|
mark_dirty ();
|
||||||
|
|
@ -226,14 +226,14 @@ ControlList::clear ()
|
||||||
void
|
void
|
||||||
ControlList::x_scale (double factor)
|
ControlList::x_scale (double factor)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
_x_scale (factor);
|
_x_scale (factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ControlList::extend_to (double when)
|
ControlList::extend_to (double when)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
if (_events.empty() || _events.back()->when == when) {
|
if (_events.empty() || _events.back()->when == when) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +268,7 @@ ControlList::thin (double thinning_factor)
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
ControlEvent* prevprev = 0;
|
ControlEvent* prevprev = 0;
|
||||||
ControlEvent* cur = 0;
|
ControlEvent* cur = 0;
|
||||||
|
|
@ -328,7 +328,7 @@ ControlList::thin (double thinning_factor)
|
||||||
void
|
void
|
||||||
ControlList::fast_simple_add (double when, double value)
|
ControlList::fast_simple_add (double when, double value)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
/* to be used only for loading pre-sorted data from saved state */
|
/* to be used only for loading pre-sorted data from saved state */
|
||||||
_events.insert (_events.end(), new ControlEvent (when, value));
|
_events.insert (_events.end(), new ControlEvent (when, value));
|
||||||
|
|
||||||
|
|
@ -338,7 +338,7 @@ ControlList::fast_simple_add (double when, double value)
|
||||||
void
|
void
|
||||||
ControlList::invalidate_insert_iterator ()
|
ControlList::invalidate_insert_iterator ()
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
unlocked_invalidate_insert_iterator ();
|
unlocked_invalidate_insert_iterator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,7 +351,7 @@ ControlList::unlocked_invalidate_insert_iterator ()
|
||||||
void
|
void
|
||||||
ControlList::start_write_pass (double when)
|
ControlList::start_write_pass (double when)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::ControlList, string_compose ("%1: setup write pass @ %2\n", this, when));
|
DEBUG_TRACE (DEBUG::ControlList, string_compose ("%1: setup write pass @ %2\n", this, when));
|
||||||
|
|
||||||
|
|
@ -557,7 +557,7 @@ ControlList::add (double when, double value, bool with_guards, bool with_default
|
||||||
this, value, when, with_guards, _in_write_pass, new_write_pass,
|
this, value, when, with_guards, _in_write_pass, new_write_pass,
|
||||||
(most_recent_insert_iterator == _events.end())));
|
(most_recent_insert_iterator == _events.end())));
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
ControlEvent cp (when, 0.0f);
|
ControlEvent cp (when, 0.0f);
|
||||||
iterator insertion_point;
|
iterator insertion_point;
|
||||||
|
|
||||||
|
|
@ -672,7 +672,7 @@ void
|
||||||
ControlList::erase (iterator i)
|
ControlList::erase (iterator i)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
if (most_recent_insert_iterator == i) {
|
if (most_recent_insert_iterator == i) {
|
||||||
unlocked_invalidate_insert_iterator ();
|
unlocked_invalidate_insert_iterator ();
|
||||||
}
|
}
|
||||||
|
|
@ -686,7 +686,7 @@ void
|
||||||
ControlList::erase (iterator start, iterator end)
|
ControlList::erase (iterator start, iterator end)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
_events.erase (start, end);
|
_events.erase (start, end);
|
||||||
unlocked_invalidate_insert_iterator ();
|
unlocked_invalidate_insert_iterator ();
|
||||||
mark_dirty ();
|
mark_dirty ();
|
||||||
|
|
@ -699,7 +699,7 @@ void
|
||||||
ControlList::erase (double when, double value)
|
ControlList::erase (double when, double value)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
iterator i = begin ();
|
iterator i = begin ();
|
||||||
while (i != end() && ((*i)->when != when || (*i)->value != value)) {
|
while (i != end() && ((*i)->when != when || (*i)->value != value)) {
|
||||||
|
|
@ -725,7 +725,7 @@ ControlList::erase_range (double start, double endt)
|
||||||
bool erased = false;
|
bool erased = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
erased = erase_range_internal (start, endt, _events);
|
erased = erase_range_internal (start, endt, _events);
|
||||||
|
|
||||||
if (erased) {
|
if (erased) {
|
||||||
|
|
@ -764,7 +764,7 @@ void
|
||||||
ControlList::slide (iterator before, double distance)
|
ControlList::slide (iterator before, double distance)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
if (before == _events.end()) {
|
if (before == _events.end()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -785,7 +785,7 @@ void
|
||||||
ControlList::shift (double pos, double frames)
|
ControlList::shift (double pos, double frames)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
for (iterator i = _events.begin(); i != _events.end(); ++i) {
|
for (iterator i = _events.begin(); i != _events.end(); ++i) {
|
||||||
if ((*i)->when >= pos) {
|
if ((*i)->when >= pos) {
|
||||||
|
|
@ -808,7 +808,7 @@ ControlList::modify (iterator iter, double when, double val)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
(*iter)->when = when;
|
(*iter)->when = when;
|
||||||
(*iter)->value = val;
|
(*iter)->value = val;
|
||||||
|
|
@ -832,7 +832,7 @@ ControlList::modify (iterator iter, double when, double val)
|
||||||
std::pair<ControlList::iterator,ControlList::iterator>
|
std::pair<ControlList::iterator,ControlList::iterator>
|
||||||
ControlList::control_points_adjacent (double xval)
|
ControlList::control_points_adjacent (double xval)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::ReaderLock lm (_lock);
|
||||||
iterator i;
|
iterator i;
|
||||||
ControlEvent cp (xval, 0.0f);
|
ControlEvent cp (xval, 0.0f);
|
||||||
std::pair<iterator,iterator> ret;
|
std::pair<iterator,iterator> ret;
|
||||||
|
|
@ -878,7 +878,7 @@ ControlList::thaw ()
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
if (_sort_pending) {
|
if (_sort_pending) {
|
||||||
_events.sort (event_time_less_than);
|
_events.sort (event_time_less_than);
|
||||||
|
|
@ -908,7 +908,7 @@ void
|
||||||
ControlList::truncate_end (double last_coordinate)
|
ControlList::truncate_end (double last_coordinate)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
ControlEvent cp (last_coordinate, 0);
|
ControlEvent cp (last_coordinate, 0);
|
||||||
ControlList::reverse_iterator i;
|
ControlList::reverse_iterator i;
|
||||||
double last_val;
|
double last_val;
|
||||||
|
|
@ -1011,7 +1011,7 @@ void
|
||||||
ControlList::truncate_start (double overall_length)
|
ControlList::truncate_start (double overall_length)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
iterator i;
|
iterator i;
|
||||||
double first_legal_value;
|
double first_legal_value;
|
||||||
double first_legal_coordinate;
|
double first_legal_coordinate;
|
||||||
|
|
@ -1276,7 +1276,7 @@ bool
|
||||||
ControlList::rt_safe_earliest_event (double start, double& x, double& y, bool inclusive) const
|
ControlList::rt_safe_earliest_event (double start, double& x, double& y, bool inclusive) const
|
||||||
{
|
{
|
||||||
// FIXME: It would be nice if this was unnecessary..
|
// FIXME: It would be nice if this was unnecessary..
|
||||||
Glib::Threads::Mutex::Lock lm(_lock, Glib::Threads::TRY_LOCK);
|
Glib::Threads::RWLock::ReaderLock lm(_lock, Glib::Threads::TRY_LOCK);
|
||||||
if (!lm.locked()) {
|
if (!lm.locked()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1480,7 +1480,7 @@ ControlList::cut_copy_clear (double start, double end, int op)
|
||||||
ControlEvent cp (start, 0.0);
|
ControlEvent cp (start, 0.0);
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
/* first, determine s & e, two iterators that define the range of points
|
/* first, determine s & e, two iterators that define the range of points
|
||||||
affected by this operation
|
affected by this operation
|
||||||
|
|
@ -1596,7 +1596,7 @@ ControlList::paste (const ControlList& alist, double pos, float /*times*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
iterator where;
|
iterator where;
|
||||||
iterator prev;
|
iterator prev;
|
||||||
double end = 0;
|
double end = 0;
|
||||||
|
|
@ -1653,7 +1653,7 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements)
|
||||||
typedef list< RangeMove<double> > RangeMoveList;
|
typedef list< RangeMove<double> > RangeMoveList;
|
||||||
|
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (_lock);
|
Glib::Threads::RWLock::WriterLock lm (_lock);
|
||||||
|
|
||||||
/* a copy of the events list before we started moving stuff around */
|
/* a copy of the events list before we started moving stuff around */
|
||||||
EventList old_events = _events;
|
EventList old_events = _events;
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ Curve::solve ()
|
||||||
bool
|
bool
|
||||||
Curve::rt_safe_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
Curve::rt_safe_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm(_list.lock(), Glib::Threads::TRY_LOCK);
|
Glib::Threads::RWLock::ReaderLock lm(_list.lock(), Glib::Threads::TRY_LOCK);
|
||||||
|
|
||||||
if (!lm.locked()) {
|
if (!lm.locked()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -184,7 +184,7 @@ Curve::rt_safe_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||||
void
|
void
|
||||||
Curve::get_vector (double x0, double x1, float *vec, int32_t veclen)
|
Curve::get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm(_list.lock());
|
Glib::Threads::RWLock::ReaderLock lm(_list.lock());
|
||||||
_get_vector (x0, x1, vec, veclen);
|
_get_vector (x0, x1, vec, veclen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue