diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/artwork/artwork.c | 28 | ||||
-rw-r--r-- | plugins/artwork/artwork.h | 2 | ||||
-rw-r--r-- | plugins/gtkui/coverart.c | 9 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 2 |
4 files changed, 37 insertions, 4 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, }; diff --git a/plugins/artwork/artwork.h b/plugins/artwork/artwork.h index 3f025fb9..247a820a 100644 --- a/plugins/artwork/artwork.h +++ b/plugins/artwork/artwork.h @@ -18,6 +18,8 @@ typedef struct { DB_misc_t plugin; // returns filename of cached image, or NULL char* (*get_album_art) (const char *fname, const char *artist, const char *album, artwork_callback callback, void *user_data); + // this has to be called to clear queue on exit, before caller terminates + void (*reset) (void); } DB_artwork_plugin_t; #endif /*__ARTWORK_H*/ diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c index af965cbf..3d9ba76b 100644 --- a/plugins/gtkui/coverart.c +++ b/plugins/gtkui/coverart.c @@ -276,9 +276,16 @@ cover_art_init (void) { void cover_art_free (void) { - trace ("terminating cover art loader thread\n"); + trace ("terminating cover art loader...\n"); + + if (coverart_plugin) { + trace ("resetting artwork plugin...\n"); + coverart_plugin->reset (); + } + if (tid) { terminate = 1; + trace ("sending terminate signal to art loader thread...\n"); deadbeef->cond_signal (cond); deadbeef->thread_join (tid); tid = 0; diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index a8ba8642..df21ce02 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -766,9 +766,9 @@ gtkui_thread (void *ctx) { ddb_listview_set_vscroll (main_playlist, scroll); gtk_main (); + cover_art_free (); gtk_widget_destroy (mainwin); gtk_widget_destroy (searchwin); - cover_art_free (); #if HAVE_NOTIFY notify_uninit (); #endif |