aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);