diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-06-29 21:44:23 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-06-29 21:44:23 +0000 |
commit | bc9a378c4f25dccbf3cc3937357a31298f2cf845 (patch) | |
tree | b812dd0bb64cceb3cfc7320196555a7bc6687fcb | |
parent | 7d6d122441e2900d873ca8f96c3ed8063176dd33 (diff) |
Crossfade works better for high bitrate vorbis files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6937 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/pcm_playback.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index 03cc106016..a7ee5cecde 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -606,30 +606,42 @@ bool pcm_insert_buffer(char *buf, long length) if (!prepare_insert(length)) return false; - - while (length > 0) { - if (crossfade_active) { + + + if (crossfade_active) { + while (length > 0 && crossfade_active) { copy_n = MIN(length, PCMBUF_SIZE - crossfade_pos); - - copy_n = 2 * crossfade((short *)&audiobuffer[crossfade_pos], - (const short *)buf, copy_n/2); + + copy_n = 2 * crossfade((short *)&audiobuffer[crossfade_pos], + (const short *)buf, copy_n/2); buf += copy_n; length -= copy_n; crossfade_pos += copy_n; if (crossfade_pos >= PCMBUF_SIZE) crossfade_pos -= PCMBUF_SIZE; - continue ; - } else { - copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos - - audiobuffer_fillpos); - copy_n = MIN(CHUNK_SIZE - audiobuffer_fillpos, copy_n); - - memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos], - buf, copy_n); + } + + while (length > 0) { + copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos); + memcpy(&audiobuffer[audiobuffer_pos], buf, copy_n); + audiobuffer_fillpos = copy_n; buf += copy_n; - audiobuffer_free -= copy_n; length -= copy_n; + if (length > 0) + pcm_flush_fillpos(); } + } + + while (length > 0) { + copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos - + audiobuffer_fillpos); + copy_n = MIN(CHUNK_SIZE - audiobuffer_fillpos, copy_n); + + memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos], + buf, copy_n); + buf += copy_n; + audiobuffer_free -= copy_n; + length -= copy_n; /* Pre-buffer to meet CHUNK_SIZE requirement */ if (copy_n + audiobuffer_fillpos < CHUNK_SIZE && length == 0) { |