summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c15
-rw-r--r--streamer.c5
2 files changed, 16 insertions, 4 deletions
diff --git a/main.c b/main.c
index 2a138159..d106bc8d 100644
--- a/main.c
+++ b/main.c
@@ -544,17 +544,24 @@ main (int argc, char *argv[]) {
// save config
pl_save (defpl);
conf_save ();
+
// stop receiving messages from outside
server_close ();
- // at this point we can simply do exit(0), but let's clean up for debugging
- messagepump_free ();
- p_free ();
+
+ // stop streaming before unloading plugins
streamer_free ();
+
+ // plugins might still hood references to playitems,
+ // and query configuration in background
+ // so unload everything 1st before final cleanup
+ plug_unload_all ();
+
+ // at this point we can simply do exit(0), but let's clean up for debugging
codec_free_locking ();
session_save (sessfile);
pl_free ();
conf_free ();
- plug_unload_all ();
+ messagepump_free ();
fprintf (stderr, "hej-hej!\n");
return 0;
}
diff --git a/streamer.c b/streamer.c
index 4a79c1b3..30a639fc 100644
--- a/streamer.c
+++ b/streamer.c
@@ -107,6 +107,9 @@ streamer_get_playing_track (void) {
// playlist must call that whenever item was removed
void
streamer_song_removed_notify (playItem_t *it) {
+ if (!mutex) {
+ return; // streamer is not running
+ }
plug_trigger_event (DB_EV_TRACKDELETED, (uintptr_t)it);
if (it == orig_playing_song) {
orig_playing_song = NULL;
@@ -492,7 +495,9 @@ streamer_free (void) {
streaming_terminate = 1;
thread_join (streamer_tid);
mutex_free (decodemutex);
+ decodemutex = 0;
mutex_free (mutex);
+ mutex = 0;
}
void