diff options
-rw-r--r-- | apps/playback.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/apps/playback.c b/apps/playback.c index 912eefef6b..847fdfae3b 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -242,6 +242,11 @@ static bool new_playlist = false; /* Are we starting a new playlist? (A) */ | |||
242 | static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ | 242 | static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ |
243 | static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer when playback resumes (A) */ | 243 | static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer when playback resumes (A) */ |
244 | 244 | ||
245 | /* Set to true if the codec thread should send an audio stop request | ||
246 | * (typically because the end of the playlist has been reached). | ||
247 | */ | ||
248 | static bool codec_requested_stop = false; | ||
249 | |||
245 | /* Callbacks which applications or plugins may set */ | 250 | /* Callbacks which applications or plugins may set */ |
246 | /* When the playing track has changed from the user's perspective */ | 251 | /* When the playing track has changed from the user's perspective */ |
247 | void (*track_changed_callback)(struct mp3entry *id3) = NULL; | 252 | void (*track_changed_callback)(struct mp3entry *id3) = NULL; |
@@ -1256,15 +1261,13 @@ static bool codec_load_next_track(void) | |||
1256 | LOGFQUEUE("codec |< Q_CODEC_REQUEST_FAILED"); | 1261 | LOGFQUEUE("codec |< Q_CODEC_REQUEST_FAILED"); |
1257 | ci.new_track = 0; | 1262 | ci.new_track = 0; |
1258 | ci.stop_codec = true; | 1263 | ci.stop_codec = true; |
1259 | LOGFQUEUE("codec > audio Q_AUDIO_STOP"); | 1264 | codec_requested_stop = true; |
1260 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | ||
1261 | return false; | 1265 | return false; |
1262 | 1266 | ||
1263 | default: | 1267 | default: |
1264 | LOGFQUEUE("codec |< default"); | 1268 | LOGFQUEUE("codec |< default"); |
1265 | ci.stop_codec = true; | 1269 | ci.stop_codec = true; |
1266 | LOGFQUEUE("codec > audio Q_AUDIO_STOP"); | 1270 | codec_requested_stop = true; |
1267 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | ||
1268 | return false; | 1271 | return false; |
1269 | } | 1272 | } |
1270 | } | 1273 | } |
@@ -1304,6 +1307,7 @@ static void codec_thread(void) | |||
1304 | status = 0; | 1307 | status = 0; |
1305 | cancel_cpu_boost(); | 1308 | cancel_cpu_boost(); |
1306 | queue_wait(&codec_queue, &ev); | 1309 | queue_wait(&codec_queue, &ev); |
1310 | codec_requested_stop = false; | ||
1307 | 1311 | ||
1308 | switch (ev.id) { | 1312 | switch (ev.id) { |
1309 | case Q_CODEC_LOAD_DISK: | 1313 | case Q_CODEC_LOAD_DISK: |
@@ -1376,6 +1380,9 @@ static void codec_thread(void) | |||
1376 | 1380 | ||
1377 | if (!codec_load_next_track()) | 1381 | if (!codec_load_next_track()) |
1378 | { | 1382 | { |
1383 | LOGFQUEUE("codec > audio Q_AUDIO_STOP"); | ||
1384 | /* End of playlist */ | ||
1385 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | ||
1379 | break; | 1386 | break; |
1380 | } | 1387 | } |
1381 | } | 1388 | } |
@@ -1392,6 +1399,12 @@ static void codec_thread(void) | |||
1392 | curtrack_id3.length - pcmbuf_get_latency(); | 1399 | curtrack_id3.length - pcmbuf_get_latency(); |
1393 | sleep(1); | 1400 | sleep(1); |
1394 | } | 1401 | } |
1402 | |||
1403 | if (codec_requested_stop) | ||
1404 | { | ||
1405 | LOGFQUEUE("codec > audio Q_AUDIO_STOP"); | ||
1406 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | ||
1407 | } | ||
1395 | break; | 1408 | break; |
1396 | } | 1409 | } |
1397 | } | 1410 | } |