From 29aad55d978282901e5bd3b95a3d2e71c0ac6c9e Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 28 Aug 2005 14:16:03 +0000 Subject: [PATCH] Fixed iriver cpu boosting problems. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7410 a1c6a512-1295-4272-9138-f99709370657 --- apps/pcmbuf.c | 2 +- apps/pcmbuf.h | 1 + apps/playback.c | 27 ++++++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index d0bbeb0265..bf5269a32e 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -93,7 +93,7 @@ void (*pcmbuf_watermark_event)(int bytes_left); static int last_chunksize; static long mixpos = 0; -static void pcmbuf_boost(bool state) +void pcmbuf_boost(bool state) { static bool boost_state = false; diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h index f2533defe6..cce7c4ec77 100644 --- a/apps/pcmbuf.h +++ b/apps/pcmbuf.h @@ -33,6 +33,7 @@ bool pcmbuf_add_chunk(void *addr, int size, void (*callback)(void)); int pcmbuf_num_used_buffers(void); void pcmbuf_set_watermark(int numbytes, void (*callback)(int bytes_left)); +void pcmbuf_boost(bool state); void pcmbuf_set_boost_mode(bool state); bool pcmbuf_is_lowdata(void); void pcmbuf_flush_audio(void); diff --git a/apps/playback.c b/apps/playback.c index 95005815fe..ffd298fbdf 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -131,6 +131,7 @@ static struct mp3entry id3_voice; static char *voicebuf; static int voice_remaining; static bool voice_is_playing; +static bool voice_cpu_boosted = false; static void (*voice_getmore)(unsigned char** start, int* size); /* Is file buffer currently being refilled? */ @@ -254,6 +255,17 @@ static void swap_codec(void) logf("codec resuming:%d", current_codec); } +static void voice_boost_cpu(bool state) +{ + if (state != voice_cpu_boosted) + { +#ifdef HAVE_ADJUSTABLE_CPU_FREQ + cpu_boost(state); +#endif + voice_cpu_boosted = state; + } +} + bool codec_pcmbuf_insert_split_callback(void *ch1, void *ch2, long length) { @@ -306,9 +318,9 @@ bool codec_pcmbuf_insert_split_callback(void *ch1, void *ch2, if (voice_is_playing && pcmbuf_usage() > 30 && pcmbuf_mix_usage() < 20) { - cpu_boost(true); + voice_boost_cpu(true); swap_codec(); - cpu_boost(false); + voice_boost_cpu(false); } break ; @@ -436,8 +448,13 @@ void* voice_request_data(long *realsize, long reqsize) { swap_codec(); } - if (!voice_is_playing) + else if (!voice_is_playing) + { + voice_boost_cpu(false); + if (!pcm_is_playing()) + pcmbuf_boost(false); sleep(HZ/16); + } if (voice_remaining) { @@ -1277,11 +1294,11 @@ void initialize_buffer_fill(void) fill_bytesleft = filebuflen - filebufused; cur_ti->start_pos = ci.curpos; - pcmbuf_set_boost_mode(true); - if (filling) return ; + pcmbuf_set_boost_mode(true); + filling = true; /* Calculate real track count after throwing away old tracks. */