diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2012-05-26 15:06:05 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2012-05-26 15:10:54 +0200 |
commit | 2c5bcc5ee10d6e982daa6660ba1925b3d95a2922 (patch) | |
tree | 5f8879251782e52d40a33a31da158f8a640f2cb2 /src/main.c | |
parent | f54c15c8b1b88c9689cadf9a9bc43a5f735f4b8e (diff) | |
download | pianobar-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.tar.gz pianobar-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.tar.bz2 pianobar-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.zip |
Revert "Remove pause mutex/add pthread cleanup function"
This reverts commit 7df9371491e96a99c1e463f7787aede352ac5a37.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -183,7 +183,7 @@ static void BarMainGetPlaylist (BarApp_t *app) { /* start new player thread */ -static void BarMainStartPlayback (BarApp_t *app) { +static void BarMainStartPlayback (BarApp_t *app, pthread_t *playerThread) { BarUiPrintSong (&app->settings, app->playlist, app->curStation->isQuickMix ? PianoFindStationById (app->ph.stations, app->playlist->stationId) : NULL); @@ -216,24 +216,26 @@ static void BarMainStartPlayback (BarApp_t *app) { * thread has been started */ app->player.mode = PLAYER_STARTING; /* start player */ - pthread_create (&app->player.thread, NULL, BarPlayerThread, + pthread_create (playerThread, NULL, BarPlayerThread, &app->player); } } /* player is done, clean up */ -static void BarMainPlayerCleanup (BarApp_t *app) { +static void BarMainPlayerCleanup (BarApp_t *app, pthread_t *playerThread) { + void *threadRet; + BarUiStartEventCmd (&app->settings, "songfinish", app->curStation, app->playlist, &app->player, app->ph.stations, PIANO_RET_OK, WAITRESS_RET_OK); /* FIXME: pthread_join blocks everything if network connection * is hung up e.g. */ - pthread_join (app->player.thread, NULL); + pthread_join (*playerThread, &threadRet); /* don't continue playback if thread reports error */ - if (app->player.ret != PLAYER_RET_OK) { + if (threadRet != (void *) PLAYER_RET_OK) { app->curStation = NULL; } @@ -263,6 +265,8 @@ static void BarMainPrintTime (BarApp_t *app) { /* main loop */ static void BarMainLoop (BarApp_t *app) { + pthread_t playerThread; + BarMainGetLoginCredentials (&app->settings, &app->input); BarMainLoadProxy (&app->settings, &app->waith); @@ -284,7 +288,7 @@ static void BarMainLoop (BarApp_t *app) { while (!app->doQuit) { /* song finished playing, clean up things/scrobble song */ if (app->player.mode == PLAYER_FINISHED_PLAYBACK) { - BarMainPlayerCleanup (app); + BarMainPlayerCleanup (app, &playerThread); } /* check whether player finished playing and start playing new @@ -301,7 +305,7 @@ static void BarMainLoop (BarApp_t *app) { } /* song ready to play */ if (app->playlist != NULL) { - BarMainStartPlayback (app); + BarMainStartPlayback (app, &playerThread); } } @@ -315,7 +319,7 @@ static void BarMainLoop (BarApp_t *app) { } if (app->player.mode != PLAYER_FREED) { - BarMainPlayerCleanup (app); + pthread_join (playerThread, NULL); } } |