From 3b90707fdd85a4b21258f6e11f10e15e0f668e3d Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Thu, 30 Jun 2005 16:28:40 +0000 Subject: Fixed a bug where a few seconds from end of a song was cut out. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6951 a1c6a512-1295-4272-9138-f99709370657 --- firmware/pcm_playback.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'firmware/pcm_playback.c') diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index a7ee5cecde..04630f100f 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -415,7 +415,7 @@ bool pcm_crossfade_init(void) */ void pcm_flush_audio(void) { - if (crossfade_init || crossfade_active) + if (crossfade_init || crossfade_active || !pcm_playing) return ; crossfade_mode = CFM_FLUSH; @@ -640,30 +640,15 @@ bool pcm_insert_buffer(char *buf, long length) memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos], buf, copy_n); buf += copy_n; - audiobuffer_free -= copy_n; + audiobuffer_fillpos += copy_n; length -= copy_n; /* Pre-buffer to meet CHUNK_SIZE requirement */ if (copy_n + audiobuffer_fillpos < CHUNK_SIZE && length == 0) { - audiobuffer_fillpos += copy_n; return true; } - - copy_n += audiobuffer_fillpos; - - while (!pcm_play_add_chunk(&audiobuffer[audiobuffer_pos], - copy_n, pcm_event_handler)) { - pcm_boost(false); - yield(); - } - pcm_event_handler = NULL; - - audiobuffer_pos += copy_n; - audiobuffer_fillpos = 0; - - if (audiobuffer_pos >= PCMBUF_SIZE) { - audiobuffer_pos = 0; - } + + pcm_flush_fillpos(); } return true; -- cgit v1.2.3