From 5f570694522225758df3f638da077a06683e9668 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sat, 11 Jun 2005 20:14:10 +0000 Subject: Fixed buffering problem with some files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6682 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 7 +++---- firmware/pcm_playback.c | 16 +++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index 739496ec73..b81ee986cb 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -431,8 +431,6 @@ void yield_codecs(void) while (pcm_is_lowdata() && !ci.stop_codec && playing && queue_empty(&audio_queue)) yield(); -#else - yield(); #endif } @@ -658,7 +656,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) close(fd); return false; } - + /* Load codec specific track tag information. */ switch (tracks[track_widx].codectype) { case AFMT_MPA_L2: @@ -666,7 +664,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) /* Should check the return value. */ mp3info(&tracks[track_widx].id3, trackname, v1first); lseek(fd, 0, SEEK_SET); - get_mp3file_info(fd, &tracks[track_widx].mp3data); + /* This is too slow to execute on some files. */ + // get_mp3file_info(fd, &tracks[track_widx].mp3data); if (offset) { lseek(fd, offset, SEEK_SET); tracks[track_widx].id3.offset = offset; diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index 12f6e08bd0..b024d7c69c 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -44,7 +44,7 @@ /* Must be a power of 2 */ #define NUM_PCM_BUFFERS (PCMBUF_SIZE / CHUNK_SIZE) #define NUM_PCM_BUFFERS_MASK (NUM_PCM_BUFFERS - 1) -#define PCM_WATERMARK 0x10000 +#define PCM_WATERMARK (CHUNK_SIZE * 3) static bool pcm_playing; static bool pcm_paused; @@ -103,7 +103,7 @@ void pcm_boost(bool state) { static bool boost_state = false; - if (crossfade_active) + if (crossfade_active || boost_mode) return ; if (state != boost_state) { @@ -348,9 +348,9 @@ void pcm_watermark_callback(int bytes_left) void pcm_set_boost_mode(bool state) { - boost_mode = state; if (state) pcm_boost(true); + boost_mode = state; } void audiobuffer_add_event(void (*event_handler)(void)) @@ -377,7 +377,7 @@ bool pcm_is_lowdata(void) if (!pcm_is_playing()) return false; - if (PCMBUF_SIZE - audiobuffer_free <= PCM_WATERMARK) + if (pcmbuf_unplayed_bytes < PCM_WATERMARK) return true; return false; @@ -421,8 +421,7 @@ bool audiobuffer_insert(char *buf, size_t length) size_t copy_n = 0; if (audiobuffer_free < length + CHUNK_SIZE && !crossfade_active) { - if (!boost_mode) - pcm_boost(false); + pcm_boost(false); return false; } @@ -448,7 +447,7 @@ bool audiobuffer_insert(char *buf, size_t length) } else { copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos - audiobuffer_fillpos); - copy_n = MIN(CHUNK_SIZE, copy_n); + copy_n = MIN(CHUNK_SIZE - audiobuffer_fillpos, copy_n); memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos], buf, copy_n); @@ -467,8 +466,7 @@ bool audiobuffer_insert(char *buf, size_t length) while (!pcm_play_add_chunk(&audiobuffer[audiobuffer_pos], copy_n, NULL)) { - if (!boost_mode) - pcm_boost(false); + pcm_boost(false); yield(); } -- cgit v1.2.3