diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2012-05-05 15:01:49 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2012-05-05 15:01:49 +0200 |
commit | c894f853294db4b3b2b9395290678cde2b1c0373 (patch) | |
tree | b9f41860171505c05b7e0cf95153bfbc14bca2f5 /src | |
parent | fefcab79e3d4a27d89700542ea4185c6f1af8a3f (diff) | |
download | pianobar-windows-c894f853294db4b3b2b9395290678cde2b1c0373.tar.gz pianobar-windows-c894f853294db4b3b2b9395290678cde2b1c0373.tar.bz2 pianobar-windows-c894f853294db4b3b2b9395290678cde2b1c0373.zip |
Avoid player mode race condition
Always run cleanup, ensure thread is joined and player struct is reset.
See #250.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -293,22 +293,19 @@ static void BarMainLoop (BarApp_t *app) { /* check whether player finished playing and start playing new * song */ - if (app->player.mode >= PLAYER_FINISHED_PLAYBACK || - app->player.mode == PLAYER_FREED) { - if (app->curStation != NULL) { - /* what's next? */ - if (app->playlist != NULL) { - PianoSong_t *histsong = app->playlist; - app->playlist = app->playlist->next; - BarUiHistoryPrepend (app, histsong); - } - if (app->playlist == NULL) { - BarMainGetPlaylist (app); - } - /* song ready to play */ - if (app->playlist != NULL) { - BarMainStartPlayback (app, &playerThread); - } + if (app->player.mode == PLAYER_FREED && app->curStation != NULL) { + /* what's next? */ + if (app->playlist != NULL) { + PianoSong_t *histsong = app->playlist; + app->playlist = app->playlist->next; + BarUiHistoryPrepend (app, histsong); + } + if (app->playlist == NULL) { + BarMainGetPlaylist (app); + } + /* song ready to play */ + if (app->playlist != NULL) { + BarMainStartPlayback (app, &playerThread); } } |