diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-04-06 19:32:35 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-04-06 19:32:35 -0400 |
commit | 5e4532c87cf747600ec1d7ae22531e89ecdce6a4 (patch) | |
tree | d65ce6f0c4fb0fd6b214ccf5f12414739f0160cd | |
parent | 1597c4fe343f4fee0821f590b592341a00362d85 (diff) | |
download | rockbox-5e4532c87cf747600ec1d7ae22531e89ecdce6a4.tar.gz rockbox-5e4532c87cf747600ec1d7ae22531e89ecdce6a4.zip |
Fix a problem with audio not starting on a list of short files
Forced audio start was left out when a third codec attempts to
start a second track transition. Only one pending transition is
allowed at a time. There wouldn't be enough PCM in the buffer to
trigger audio playback and audio would just return without giving
the pcm buffer a kick.
Fixes FS#13100 - Player failed on short tracks
Change-Id: I338b0b12022c591930451fd5ed26a2a73008835f
-rw-r--r-- | apps/pcmbuf.c | 31 | ||||
-rw-r--r-- | apps/pcmbuf.h | 1 | ||||
-rw-r--r-- | apps/playback.c | 7 |
3 files changed, 30 insertions, 9 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 6e2c51c80a..773e97cce0 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c | |||
@@ -204,6 +204,13 @@ extern void audio_pcmbuf_sync_position(void); | |||
204 | 204 | ||
205 | /**************************************/ | 205 | /**************************************/ |
206 | 206 | ||
207 | /* start PCM if callback says it's alright */ | ||
208 | static void start_audio_playback(void) | ||
209 | { | ||
210 | if (audio_pcmbuf_may_play()) | ||
211 | pcmbuf_play_start(); | ||
212 | } | ||
213 | |||
207 | /* Return number of commited bytes in buffer (committed chunks count as | 214 | /* Return number of commited bytes in buffer (committed chunks count as |
208 | a full chunk even if only partially filled) */ | 215 | a full chunk even if only partially filled) */ |
209 | static size_t pcmbuf_unplayed_bytes(void) | 216 | static size_t pcmbuf_unplayed_bytes(void) |
@@ -492,8 +499,8 @@ void * pcmbuf_request_buffer(int *count) | |||
492 | trigger_cpu_boost(); | 499 | trigger_cpu_boost(); |
493 | 500 | ||
494 | /* If pre-buffered to the watermark, start playback */ | 501 | /* If pre-buffered to the watermark, start playback */ |
495 | if (!pcmbuf_data_critical() && audio_pcmbuf_may_play()) | 502 | if (!pcmbuf_data_critical()) |
496 | pcmbuf_play_start(); | 503 | start_audio_playback(); |
497 | } | 504 | } |
498 | 505 | ||
499 | void *buf; | 506 | void *buf; |
@@ -672,15 +679,22 @@ void pcmbuf_monitor_track_change(bool monitor) | |||
672 | 679 | ||
673 | void pcmbuf_start_track_change(enum pcm_track_change_type type) | 680 | void pcmbuf_start_track_change(enum pcm_track_change_type type) |
674 | { | 681 | { |
682 | /* Commit all outstanding data before starting next track - tracks don't | ||
683 | comingle inside a single buffer chunk */ | ||
684 | commit_if_needed(COMMIT_ALL_DATA); | ||
685 | |||
686 | if (type == TRACK_CHANGE_AUTO_PILEUP) | ||
687 | { | ||
688 | /* Fill might not have been above watermark */ | ||
689 | start_audio_playback(); | ||
690 | return; | ||
691 | } | ||
692 | |||
675 | #ifdef HAVE_CROSSFADE | 693 | #ifdef HAVE_CROSSFADE |
676 | bool crossfade = false; | 694 | bool crossfade = false; |
677 | #endif | 695 | #endif |
678 | bool auto_skip = type != TRACK_CHANGE_MANUAL; | 696 | bool auto_skip = type != TRACK_CHANGE_MANUAL; |
679 | 697 | ||
680 | /* Commit all outstanding data before starting next track - tracks don't | ||
681 | comingle inside a single buffer chunk */ | ||
682 | commit_if_needed(COMMIT_ALL_DATA); | ||
683 | |||
684 | /* Update position key so that: | 698 | /* Update position key so that: |
685 | 1) Positions are keyed to the track to which they belong for sync | 699 | 1) Positions are keyed to the track to which they belong for sync |
686 | purposes | 700 | purposes |
@@ -695,9 +709,8 @@ void pcmbuf_start_track_change(enum pcm_track_change_type type) | |||
695 | { | 709 | { |
696 | crossfade_cancel(); | 710 | crossfade_cancel(); |
697 | 711 | ||
698 | /* If end of all data, force playback */ | 712 | /* Fill might not have been above watermark */ |
699 | if (audio_pcmbuf_may_play()) | 713 | start_audio_playback(); |
700 | pcmbuf_play_start(); | ||
701 | } | 714 | } |
702 | #ifdef HAVE_CROSSFADE | 715 | #ifdef HAVE_CROSSFADE |
703 | /* Determine whether this track change needs to crossfaded and how */ | 716 | /* Determine whether this track change needs to crossfaded and how */ |
diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h index e16f86174c..33422bbee5 100644 --- a/apps/pcmbuf.h +++ b/apps/pcmbuf.h | |||
@@ -43,6 +43,7 @@ enum pcm_track_change_type | |||
43 | TRACK_CHANGE_NONE = 0, /* No track change pending */ | 43 | TRACK_CHANGE_NONE = 0, /* No track change pending */ |
44 | TRACK_CHANGE_MANUAL, /* Manual change (from user) */ | 44 | TRACK_CHANGE_MANUAL, /* Manual change (from user) */ |
45 | TRACK_CHANGE_AUTO, /* Automatic change (from codec) */ | 45 | TRACK_CHANGE_AUTO, /* Automatic change (from codec) */ |
46 | TRACK_CHANGE_AUTO_PILEUP, /* Auto change during pending change */ | ||
46 | TRACK_CHANGE_END_OF_DATA, /* Expect no more data (from codec) */ | 47 | TRACK_CHANGE_END_OF_DATA, /* Expect no more data (from codec) */ |
47 | }; | 48 | }; |
48 | void pcmbuf_monitor_track_change(bool monitor); | 49 | void pcmbuf_monitor_track_change(bool monitor); |
diff --git a/apps/playback.c b/apps/playback.c index 8a25375fec..54410ad2cc 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -2376,9 +2376,16 @@ static void audio_on_codec_complete(int status) | |||
2376 | Skipping: There was already a skip in progress, remember it and | 2376 | Skipping: There was already a skip in progress, remember it and |
2377 | allow no further progress until the PCM from the previous | 2377 | allow no further progress until the PCM from the previous |
2378 | song has finished | 2378 | song has finished |
2379 | |||
2380 | This function will be reentered upon completing the existing | ||
2381 | transition in order to do the one that was just tried (below) | ||
2379 | */ | 2382 | */ |
2380 | codec_skip_pending = true; | 2383 | codec_skip_pending = true; |
2381 | codec_skip_status = status; | 2384 | codec_skip_status = status; |
2385 | |||
2386 | /* PCM buffer must know; audio could still be filling and hasn't | ||
2387 | yet reached the play watermark */ | ||
2388 | pcmbuf_start_track_change(TRACK_CHANGE_AUTO_PILEUP); | ||
2382 | return; | 2389 | return; |
2383 | } | 2390 | } |
2384 | 2391 | ||