summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-06-29 11:50:41 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-06-29 11:50:41 +0000
commit0441afecd7ecb7024609224fc6ab39b7bedab273 (patch)
tree90728c0e11e3158516bd93b543f7f26fd47e1bb9 /apps/playback.c
parent4e15aead43c9bbecf8a13c146ac38685afa0d200 (diff)
downloadrockbox-0441afecd7ecb7024609224fc6ab39b7bedab273.tar.gz
rockbox-0441afecd7ecb7024609224fc6ab39b7bedab273.zip
Fix FS#9110 and its maybe-dupes.
The issue happened when the value of 'filling' was STATE_FINISHED: the low_buffer_callback wouldn't do anything even when there would still be data remaining to be buffered, leading to a shortage of audio data. Only making the callback act even when filling is STATE_FINISHED (the simple fix) isn't right because of cases when the last track in the playlist is fully buffered. Therefore I added a new state to distinguish between when the last track is fully buffered (STATE_FINISHED) and when it isn't (STATE_END_OF_PLAYLIST). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17875 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/playback.c b/apps/playback.c
index d85bdcbd19..aee06b07ae 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -151,7 +151,8 @@ enum filling_state {
151 STATE_IDLE, /* audio is stopped: nothing to do */ 151 STATE_IDLE, /* audio is stopped: nothing to do */
152 STATE_FILLING, /* adding tracks to the buffer */ 152 STATE_FILLING, /* adding tracks to the buffer */
153 STATE_FULL, /* can't add any more tracks */ 153 STATE_FULL, /* can't add any more tracks */
154 STATE_FINISHED, /* all remaining tracks have been added */ 154 STATE_END_OF_PLAYLIST, /* all remaining tracks have been added */
155 STATE_FINISHED, /* all remaining tracks are fully buffered */
155}; 156};
156 157
157#if MEM > 1 158#if MEM > 1
@@ -1413,7 +1414,7 @@ static void buffering_low_buffer_callback(void *data)
1413 (void)data; 1414 (void)data;
1414 logf("low buffer callback"); 1415 logf("low buffer callback");
1415 1416
1416 if (filling == STATE_FULL) { 1417 if (filling == STATE_FULL || filling == STATE_END_OF_PLAYLIST) {
1417 /* force a refill */ 1418 /* force a refill */
1418 LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER"); 1419 LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");
1419 queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0); 1420 queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);
@@ -1443,6 +1444,15 @@ static void buffering_handle_finished_callback(int *data)
1443 /* This is most likely an audio handle, so we strip the useless 1444 /* This is most likely an audio handle, so we strip the useless
1444 trailing tags that are left. */ 1445 trailing tags that are left. */
1445 strip_tags(*data); 1446 strip_tags(*data);
1447
1448 if (*data == tracks[track_widx-1].audio_hid
1449 && filling == STATE_END_OF_PLAYLIST)
1450 {
1451 /* This was the last track in the playlist.
1452 We now have all the data we need. */
1453 logf("last track finished buffering");
1454 filling = STATE_FINISHED;
1455 }
1446 } 1456 }
1447} 1457}
1448 1458
@@ -1634,7 +1644,7 @@ static bool audio_load_track(size_t offset, bool start_play)
1634 { 1644 {
1635 logf("End-of-playlist"); 1645 logf("End-of-playlist");
1636 memset(&lasttrack_id3, 0, sizeof(struct mp3entry)); 1646 memset(&lasttrack_id3, 0, sizeof(struct mp3entry));
1637 filling = STATE_FINISHED; 1647 filling = STATE_END_OF_PLAYLIST;
1638 return false; 1648 return false;
1639 } 1649 }
1640 1650