summaryrefslogtreecommitdiff
path: root/plugins/artwork/artwork.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-13 18:23:06 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-13 18:23:06 +0100
commit3438d32384da18fa4b1ebaa397efabfcb981c0f7 (patch)
tree80e051a89b7233458341f1c115eddc9986ff02a4 /plugins/artwork/artwork.c
parent5275fa39d310a058b26a3c3183d45498633042a2 (diff)
fixed random crash on exit, while cover art is being loaded in background
Diffstat (limited to 'plugins/artwork/artwork.c')
-rw-r--r--plugins/artwork/artwork.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index ed63b44f..47e43d69 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -34,7 +34,8 @@ static cover_query_t *queue;
static cover_query_t *queue_tail;
static uintptr_t mutex;
static uintptr_t cond;
-static int terminate;
+static volatile int terminate;
+static volatile int clear_queue;
static intptr_t tid;
void
@@ -274,7 +275,7 @@ fetcher_thread (void *none)
deadbeef->cond_wait (cond, mutex);
trace ("artwork: cond signalled\n");
deadbeef->mutex_unlock (mutex);
- while (!terminate && queue) {
+ while (!terminate && queue && !clear_queue) {
cover_query_t *param = queue;
char path [1024];
struct dirent **files;
@@ -343,6 +344,15 @@ fetcher_thread (void *none)
}
queue_pop ();
}
+ if (clear_queue) {
+ trace ("artwork: received queue clear request\n");
+ while (queue) {
+ queue_pop ();
+ }
+ clear_queue = 0;
+ trace ("artwork: queue clear done\n");
+ continue;
+ }
if (terminate) {
break;
}
@@ -386,6 +396,19 @@ artwork_load (DB_functions_t *api) {
return DB_PLUGIN (&plugin);
}
+void
+artwork_reset (void) {
+ trace ("artwork: reset\n");
+ clear_queue = 1;
+ deadbeef->mutex_lock (mutex);
+ deadbeef->mutex_unlock (mutex);
+ deadbeef->cond_signal (cond);
+ trace ("artwork: waiting for clear to complete\n");
+ while (clear_queue) {
+ usleep (100000);
+ }
+}
+
static int
artwork_plugin_start (void)
{
@@ -431,4 +454,5 @@ static DB_artwork_plugin_t plugin = {
.plugin.plugin.start = artwork_plugin_start,
.plugin.plugin.stop = artwork_plugin_stop,
.get_album_art = get_album_art,
+ .reset = artwork_reset,
};