summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c3
-rw-r--r--src/player.h15
2 files changed, 14 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 82ed674..5428653 100644
--- a/src/main.c
+++ b/src/main.c
@@ -248,6 +248,9 @@ int main (int argc, char **argv) {
BarUiStartEventCmd (&settings, "songstart", curStation,
playlist, &player, PIANO_RET_OK);
+ /* prevent race condition, mode must _not_ be FREED if
+ * thread has been started */
+ player.mode = PLAYER_STARTING;
/* start player */
pthread_create (&playerThread, NULL, BarPlayerThread,
&player);
diff --git a/src/player.h b/src/player.h
index 82a6cd5..249fc6f 100644
--- a/src/player.h
+++ b/src/player.h
@@ -49,10 +49,17 @@ struct audioPlayer {
size_t bufferRead;
size_t bytesReceived;
- enum {PLAYER_FREED = 0, PLAYER_INITIALIZED, PLAYER_FOUND_ESDS,
- PLAYER_AUDIO_INITIALIZED, PLAYER_FOUND_STSZ,
- PLAYER_SAMPLESIZE_INITIALIZED, PLAYER_RECV_DATA,
- PLAYER_FINISHED_PLAYBACK} mode;
+ enum {
+ PLAYER_FREED = 0, /* thread is not running */
+ PLAYER_STARTING, /* thread is starting */
+ PLAYER_INITIALIZED, /* decoder/waitress initialized */
+ PLAYER_FOUND_ESDS,
+ PLAYER_AUDIO_INITIALIZED, /* audio device opened */
+ PLAYER_FOUND_STSZ,
+ PLAYER_SAMPLESIZE_INITIALIZED,
+ PLAYER_RECV_DATA, /* playing track */
+ PLAYER_FINISHED_PLAYBACK
+ } mode;
PianoAudioFormat_t audioFormat;