WaveViewCache* WaveView::images = 0;
gint WaveView::drawing_thread_should_quit = 0;
Glib::Threads::Mutex WaveView::request_queue_lock;
+Glib::Threads::Mutex WaveView::current_image_lock;
Glib::Threads::Cond WaveView::request_cond;
Glib::Threads::Thread* WaveView::_drawing_thread = 0;
WaveView::DrawingRequestQueue WaveView::request_queue;
WaveView::~WaveView ()
{
invalidate_image_cache ();
+ if (images ) {
+ images->clear_cache ();
+ }
}
string
{
DEBUG_TRACE (DEBUG::WaveView, string_compose ("%1 invalidates image cache and cancels current request\n", this));
cancel_my_render_request ();
+ Glib::Threads::Mutex::Lock lci (current_image_lock);
_current_image.reset ();
}
} else {
draw_absent_image (req->image, peaks.get(), n_peaks);
}
+ } else {
+ cerr << "Request stopped before image generation\n";
}
if (in_render_thread && !req->should_stop()) {
DEBUG_TRACE (DEBUG::WaveView, string_compose ("done with request for %1 at %2 CR %3 req %4 range %5 .. %6\n", this, g_get_monotonic_time(), current_request, req, req->start, req->end));
const_cast<WaveView*>(this)->ImageReady (); /* emit signal */
}
+
+ cerr << "Generate image done, image = " << req->image << endl;
return;
}
double image_origin_in_self_coordinates;
boost::shared_ptr<WaveViewCache::Entry> image_to_draw;
+ Glib::Threads::Mutex::Lock lci (current_image_lock);
if (_current_image) {
/* check it covers the right sample range */
double draw_width;
if (image_to_draw != _current_image) {
+ lci.release ();
/* the image is guaranteed to start at or before
* draw_start. But if it starts before draw_start, that reduces
request_cond.wait (request_queue_lock);
}
+ if (request_queue.empty()) {
+ assert (g_atomic_int_get (&drawing_thread_should_quit));
+ continue; // or break;
+ }
+
/* remove the request from the queue (remember: the "request"
* is just a pointer to a WaveView object)
*/