From ed7b2597a439c27e60d0b4cec85e801c9099173c Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 26 May 2012 15:50:18 +0200 Subject: Move mutex initalization to main thread Closes #250. --- src/main.c | 4 +++- src/player.c | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 3e7ac54..b140e20 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2011 +Copyright (c) 2008-2012 Lars-Dominik Braun Permission is hereby granted, free of charge, to any person obtaining a copy @@ -206,6 +206,7 @@ static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) { app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume); app->player.audioFormat = app->playlist->audioFormat; app->player.settings = &app->settings; + pthread_mutex_init (&app->player.pauseMutex, NULL); /* throw event */ BarUiStartEventCmd (&app->settings, "songstart", @@ -233,6 +234,7 @@ static void BarMainPlayerCleanup (BarApp_t *app, pthread_t *playerThread) { /* FIXME: pthread_join blocks everything if network connection * is hung up e.g. */ pthread_join (*playerThread, &threadRet); + pthread_mutex_destroy (&app->player.pauseMutex); /* don't continue playback if thread reports error */ if (threadRet != (void *) PLAYER_RET_OK) { diff --git a/src/player.c b/src/player.c index 733a315..3877906 100644 --- a/src/player.c +++ b/src/player.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2011 +Copyright (c) 2008-2012 Lars-Dominik Braun Permission is hereby granted, free of charge, to any person obtaining a copy @@ -421,7 +421,6 @@ void *BarPlayerThread (void *data) { WaitressReturn_t wRet = WAITRESS_RET_ERR; /* init handles */ - pthread_mutex_init (&player->pauseMutex, NULL); player->waith.data = (void *) player; /* extraHeaders will be initialized later */ player->waith.extraHeaders = extraHeaders; @@ -500,7 +499,6 @@ void *BarPlayerThread (void *data) { ao_close(player->audioOutDevice); WaitressFree (&player->waith); - pthread_mutex_destroy (&player->pauseMutex); free (player->buffer); player->mode = PLAYER_FINISHED_PLAYBACK; -- cgit v1.2.3