summaryrefslogtreecommitdiff
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-04-06 19:32:35 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-04-06 19:32:35 -0400
commit5e4532c87cf747600ec1d7ae22531e89ecdce6a4 (patch)
treed65ce6f0c4fb0fd6b214ccf5f12414739f0160cd /apps/pcmbuf.c
parent1597c4fe343f4fee0821f590b592341a00362d85 (diff)
downloadrockbox-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
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r--apps/pcmbuf.c31
1 files changed, 22 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 */
208static 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) */
209static size_t pcmbuf_unplayed_bytes(void) 216static 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
673void pcmbuf_start_track_change(enum pcm_track_change_type type) 680void 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 */