decoder_control: added decoder_control.thread
decoder_control.thread contains the handle of the decoder thread, or NULL if the decoder thread isn't running.
This commit is contained in:
@@ -102,8 +102,13 @@ dc_seek(struct notify *notify, double where)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dc_quit(struct notify *notify)
|
dc_quit(void)
|
||||||
{
|
{
|
||||||
|
assert(dc.thread != NULL);
|
||||||
|
|
||||||
dc.quit = true;
|
dc.quit = true;
|
||||||
dc_command(notify, DECODE_COMMAND_STOP);
|
dc_command_async(DECODE_COMMAND_STOP);
|
||||||
|
|
||||||
|
g_thread_join(dc.thread);
|
||||||
|
dc.thread = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,10 @@ enum decoder_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct decoder_control {
|
struct decoder_control {
|
||||||
|
/** the handle of the decoder thread, or NULL if the decoder
|
||||||
|
thread isn't running */
|
||||||
|
GThread *thread;
|
||||||
|
|
||||||
struct notify notify;
|
struct notify notify;
|
||||||
|
|
||||||
volatile enum decoder_state state;
|
volatile enum decoder_state state;
|
||||||
@@ -124,6 +128,6 @@ bool
|
|||||||
dc_seek(struct notify *notify, double where);
|
dc_seek(struct notify *notify, double where);
|
||||||
|
|
||||||
void
|
void
|
||||||
dc_quit(struct notify *notify);
|
dc_quit(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -258,8 +258,10 @@ static gpointer decoder_task(G_GNUC_UNUSED gpointer arg)
|
|||||||
void decoder_thread_start(void)
|
void decoder_thread_start(void)
|
||||||
{
|
{
|
||||||
GError *e = NULL;
|
GError *e = NULL;
|
||||||
GThread *t;
|
|
||||||
|
|
||||||
if (!(t = g_thread_create(decoder_task, NULL, FALSE, &e)))
|
assert(dc.thread == NULL);
|
||||||
|
|
||||||
|
dc.thread = g_thread_create(decoder_task, NULL, true, &e);
|
||||||
|
if (dc.thread == NULL)
|
||||||
FATAL("Failed to spawn decoder task: %s\n", e->message);
|
FATAL("Failed to spawn decoder task: %s\n", e->message);
|
||||||
}
|
}
|
||||||
|
@@ -526,7 +526,7 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PLAYER_COMMAND_EXIT:
|
case PLAYER_COMMAND_EXIT:
|
||||||
dc_quit(&pc.notify);
|
dc_quit();
|
||||||
closeAudioDevice();
|
closeAudioDevice();
|
||||||
player_command_finished();
|
player_command_finished();
|
||||||
g_thread_exit(NULL);
|
g_thread_exit(NULL);
|
||||||
|
Reference in New Issue
Block a user