mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
don't queue a callback with the idle event for waveview image generation if one is already queued.
Also, hold relevant lock when waking image rendering thread.
This commit is contained in:
parent
ceb3c38090
commit
077e625734
2 changed files with 20 additions and 10 deletions
|
|
@ -310,6 +310,7 @@ public:
|
||||||
double _amplitude_above_axis;
|
double _amplitude_above_axis;
|
||||||
float _region_amplitude;
|
float _region_amplitude;
|
||||||
double _start_shift;
|
double _start_shift;
|
||||||
|
mutable bool idle_queued;
|
||||||
|
|
||||||
/** The `start' value to use for the region; we can't use the region's
|
/** The `start' value to use for the region; we can't use the region's
|
||||||
* value as the crossfade editor needs to alter it.
|
* value as the crossfade editor needs to alter it.
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ WaveView::WaveView (Canvas* c, boost::shared_ptr<ARDOUR::AudioRegion> region)
|
||||||
, _amplitude_above_axis (1.0)
|
, _amplitude_above_axis (1.0)
|
||||||
, _region_amplitude (region->scale_amplitude ())
|
, _region_amplitude (region->scale_amplitude ())
|
||||||
, _start_shift (0.0)
|
, _start_shift (0.0)
|
||||||
|
, idle_queued (false)
|
||||||
, _region_start (region->start())
|
, _region_start (region->start())
|
||||||
, get_image_in_thread (false)
|
, get_image_in_thread (false)
|
||||||
, always_get_image_in_thread (false)
|
, always_get_image_in_thread (false)
|
||||||
|
|
@ -115,6 +116,8 @@ WaveView::WaveView (Item* parent, boost::shared_ptr<ARDOUR::AudioRegion> region)
|
||||||
, _gradient_depth_independent (false)
|
, _gradient_depth_independent (false)
|
||||||
, _amplitude_above_axis (1.0)
|
, _amplitude_above_axis (1.0)
|
||||||
, _region_amplitude (region->scale_amplitude ())
|
, _region_amplitude (region->scale_amplitude ())
|
||||||
|
, _start_shift (0.0)
|
||||||
|
, idle_queued (false)
|
||||||
, _region_start (region->start())
|
, _region_start (region->start())
|
||||||
, get_image_in_thread (false)
|
, get_image_in_thread (false)
|
||||||
, always_get_image_in_thread (false)
|
, always_get_image_in_thread (false)
|
||||||
|
|
@ -1342,7 +1345,6 @@ WaveView::set_start_shift (double pixels)
|
||||||
_start_shift = pixels;
|
_start_shift = pixels;
|
||||||
end_visual_change ();
|
end_visual_change ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WaveView::cancel_my_render_request () const
|
WaveView::cancel_my_render_request () const
|
||||||
|
|
@ -1381,20 +1383,27 @@ WaveView::send_request (boost::shared_ptr<WaveViewThreadRequest> req) const
|
||||||
|
|
||||||
start_drawing_thread ();
|
start_drawing_thread ();
|
||||||
|
|
||||||
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &WaveView::idle_send_request), req));
|
/* this is always called from the GUI thread (there is only one), and
|
||||||
|
* the same thread runs the idle callback chain. thus we do not need
|
||||||
|
* any locks to protect idle_queued - it is only ever set or read in
|
||||||
|
* the unitary GUI thread.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!idle_queued) {
|
||||||
|
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &WaveView::idle_send_request), req));
|
||||||
|
idle_queued = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WaveView::idle_send_request (boost::shared_ptr<WaveViewThreadRequest> req) const
|
WaveView::idle_send_request (boost::shared_ptr<WaveViewThreadRequest> req) const
|
||||||
{
|
{
|
||||||
{
|
Glib::Threads::Mutex::Lock lm (request_queue_lock);
|
||||||
Glib::Threads::Mutex::Lock lm (request_queue_lock);
|
/* swap requests (protected by lock) */
|
||||||
/* swap requests (protected by lock) */
|
current_request = req;
|
||||||
current_request = req;
|
request_queue.insert (this);
|
||||||
request_queue.insert (this);
|
request_cond.signal (); /* wake thread - must be done while holding lock */
|
||||||
}
|
idle_queued = false;
|
||||||
|
|
||||||
request_cond.signal (); /* wake thread */
|
|
||||||
|
|
||||||
return false; /* do not call from idle again */
|
return false; /* do not call from idle again */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue