aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-28 19:48:53 +0100
committerMax Kellermann <max@duempel.org>2008-12-28 19:48:53 +0100
commit8fe03b8bcef9f5a3a822055a3c4ab65cfe1baedb (patch)
treeddb22a695b4a2643cbf77e699e2d5a5f0cbcd2ab
parentc01aa53e6a972cd83e866b6b2e390449f2a59658 (diff)
downloadmpd-8fe03b8bcef9f5a3a822055a3c4ab65cfe1baedb.tar.gz
mpd-8fe03b8bcef9f5a3a822055a3c4ab65cfe1baedb.tar.xz
mpd-8fe03b8bcef9f5a3a822055a3c4ab65cfe1baedb.zip
decoder: terminate decoder thread before MPD cleanup
When MPD exits, it should manually free all resources in use, to allow easy memory leak debugging. Make the decoder thread terminate during that.
Diffstat (limited to '')
-rw-r--r--src/decoder_control.c7
-rw-r--r--src/decoder_control.h4
-rw-r--r--src/decoder_thread.c4
-rw-r--r--src/player_thread.c1
4 files changed, 14 insertions, 2 deletions
diff --git a/src/decoder_control.c b/src/decoder_control.c
index efc8ac797..b934d516f 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -100,3 +100,10 @@ dc_seek(struct notify *notify, double where)
return true;
}
+
+void
+dc_quit(struct notify *notify)
+{
+ dc.quit = true;
+ dc_command(notify, DECODE_COMMAND_STOP);
+}
diff --git a/src/decoder_control.h b/src/decoder_control.h
index e9fa449e6..4fd0f9edc 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -49,6 +49,7 @@ struct decoder_control {
volatile enum decoder_state state;
volatile enum decoder_command command;
+ bool quit;
bool seek_error;
bool seekable;
volatile double seek_where;
@@ -122,4 +123,7 @@ dc_stop(struct notify *notify);
bool
dc_seek(struct notify *notify, double where);
+void
+dc_quit(struct notify *notify);
+
#endif
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 0ae1a88f9..2be0937da 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -204,7 +204,7 @@ static void decoder_run(void)
static void * decoder_task(G_GNUC_UNUSED void *arg)
{
- while (1) {
+ do {
assert(dc.state == DECODE_STATE_STOP ||
dc.state == DECODE_STATE_ERROR);
@@ -226,7 +226,7 @@ static void * decoder_task(G_GNUC_UNUSED void *arg)
notify_wait(&dc.notify);
break;
}
- }
+ } while (dc.command != DECODE_COMMAND_NONE || !dc.quit);
return NULL;
}
diff --git a/src/player_thread.c b/src/player_thread.c
index 7da412dfa..a831bae3b 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -514,6 +514,7 @@ static void * player_task(G_GNUC_UNUSED void *arg)
break;
case PLAYER_COMMAND_EXIT:
+ dc_quit(&pc.notify);
closeAudioDevice();
player_command_finished();
pthread_exit(NULL);