From c894f853294db4b3b2b9395290678cde2b1c0373 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 5 May 2012 15:01:49 +0200 Subject: Avoid player mode race condition Always run cleanup, ensure thread is joined and player struct is reset. See #250. --- src/main.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 26099f5..b2b0ea5 100644 --- a/src/main.c +++ b/src/main.c @@ -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); } } -- cgit v1.2.3