player_thread: migrate from pthread to glib threads

This commit is contained in:
Thomas Jansen 2008-12-28 22:09:38 +01:00
parent c01ad37d3b
commit 195cec505e

View File

@ -493,7 +493,7 @@ static void do_play(void)
player_stop_decoder(); player_stop_decoder();
} }
static void * player_task(G_GNUC_UNUSED void *arg) static gpointer player_task(G_GNUC_UNUSED gpointer arg)
{ {
while (1) { while (1) {
switch (pc.command) { switch (pc.command) {
@ -517,7 +517,7 @@ static void * player_task(G_GNUC_UNUSED void *arg)
dc_quit(&pc.notify); dc_quit(&pc.notify);
closeAudioDevice(); closeAudioDevice();
player_command_finished(); player_command_finished();
pthread_exit(NULL); g_thread_exit(NULL);
break; break;
case PLAYER_COMMAND_CANCEL: case PLAYER_COMMAND_CANCEL:
@ -535,11 +535,9 @@ static void * player_task(G_GNUC_UNUSED void *arg)
void player_create(void) void player_create(void)
{ {
pthread_attr_t attr; GError *e;
pthread_t player_thread; GThread *t;
pthread_attr_init(&attr); if (!(t = g_thread_create(player_task, NULL, FALSE, &e)))
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); FATAL("Failed to spawn player task: %s\n", e->message);
if (pthread_create(&player_thread, &attr, player_task, NULL))
FATAL("Failed to spawn player task: %s\n", strerror(errno));
} }