summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-05-05 15:01:49 +0200
committerLars-Dominik Braun <lars@6xq.net>2012-05-05 15:01:49 +0200
commitc894f853294db4b3b2b9395290678cde2b1c0373 (patch)
treeb9f41860171505c05b7e0cf95153bfbc14bca2f5 /src/main.c
parentfefcab79e3d4a27d89700542ea4185c6f1af8a3f (diff)
downloadpianobar-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/main.c')
-rw-r--r--src/main.c29
1 files changed, 13 insertions, 16 deletions
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);
}
}