From 2ed0b195be62161df9fbeaa58abfe762f86959e6 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Fri, 10 Jun 2005 10:58:45 +0000 Subject: Better handling for cpu_boost(). Small buffering fix. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6647 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'apps/playback.c') diff --git a/apps/playback.c b/apps/playback.c index 9abc3e38a9..2f67b6c3ba 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -438,8 +438,8 @@ void audio_fill_file_buffer(void) } buf_widx += rc; - if (buf_widx == codecbuflen) - buf_widx = 0; + if (buf_widx >= codecbuflen) + buf_widx -= codecbuflen; i += rc; tracks[track_widx].available += rc; fill_bytesleft -= rc; @@ -552,7 +552,7 @@ bool loadcodec(const char *trackname, bool start_play) return false; buf_widx += rc; if (buf_widx >= codecbuflen) - buf_widx = 0; + buf_widx -= codecbuflen; i += rc; } close(fd); @@ -598,7 +598,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) /* Load the codec */ if (buf_widx >= codecbuflen) - buf_widx = 0; + buf_widx -= codecbuflen; tracks[track_widx].codecbuf = &codecbuf[buf_widx]; if (!loadcodec(trackname, start_play)) { @@ -742,15 +742,15 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) } buf_widx += rc; if (buf_widx >= codecbuflen) - buf_widx = 0; + buf_widx -= codecbuflen; i += rc; tracks[track_widx].available += rc; tracks[track_widx].filerem -= rc; + codecbufused += rc; fill_bytesleft -= rc; } tracks[track_widx].filepos = i; - codecbufused += i; /* Leave the file handle open for faster buffer refill. */ if (tracks[track_widx].filerem != 0) { @@ -809,8 +809,8 @@ void audio_check_buffer(void) /* Fill buffer as full as possible for cross-fader. */ #ifndef SIMULATOR - if (cur_ti->id3.length > 0 && - cur_ti->id3.length - cur_ti->id3.elapsed < 20000 && playing) + if (pcm_is_crossfade_enabled() && cur_ti->id3.length > 0 + && cur_ti->id3.length - cur_ti->id3.elapsed < 20000 && playing) pcm_set_boost_mode(true); #endif @@ -873,6 +873,7 @@ void audio_update_trackinfo(void) cur_ti = &tracks[track_ridx]; buf_ridx += cur_ti->codecsize; + codecbufused -= cur_ti->codecsize; if (buf_ridx >= codecbuflen) buf_ridx -= codecbuflen; #ifndef SIMULATOR @@ -989,7 +990,7 @@ void audio_thread(void) struct event ev; while (1) { - yield(); + sleep(50); audio_check_buffer(); queue_wait_w_tmo(&audio_queue, &ev, 10); -- cgit v1.2.3