? tools/codepages ? tools/mkboot ? tools/rdf2binary Index: apps/pcmbuf.c =================================================================== RCS file: /cvsroot/rockbox/apps/pcmbuf.c,v retrieving revision 1.25 diff -u -r1.25 pcmbuf.c --- apps/pcmbuf.c 27 Jan 2006 16:25:44 -0000 1.25 +++ apps/pcmbuf.c 31 Jan 2006 00:13:47 -0000 @@ -183,6 +183,26 @@ pcmbuf_watermark = numbytes; } +#ifdef TIME_CODEC +static unsigned long start_tick; +static unsigned long last_tick; +static unsigned long bytes_played; +static bool fake_pcm_is_playing = false; +extern bool is_filling(void); +bool pcmbuf_add_chunk(void *addr, int size, void (*callback)(void)) +{ + (void)callback; + (void)addr; + if (!bytes_played) { + while (is_filling()) + sleep(HZ/2); + start_tick = current_tick; + } + bytes_played += size; + last_tick = current_tick; + return true; +} +#else bool pcmbuf_add_chunk(void *addr, int size, void (*callback)(void)) { /* We don't use the last buffer, since we can't see the difference @@ -200,6 +220,7 @@ else return false; } +#endif static void pcmbuf_under_watermark(int bytes_left) { @@ -256,6 +277,16 @@ } +#ifdef TIME_CODEC +void pcmbuf_display_timing(void) { + if (!bytes_played) return; + unsigned int centipercent_realtime = (unsigned long long)bytes_played * + HZ / (last_tick - start_tick) * 10000 / (NATIVE_FREQUENCY*4); + gui_syncsplash(HZ*3, true, "Realtime percent: %ld.%02ld%%", + centipercent_realtime/100,centipercent_realtime%100); +} +#endif + void pcmbuf_play_stop(void) { mutex_lock(&pcmbuf_mutex); @@ -263,7 +294,12 @@ /** Prevent a very tiny pop from happening by muting audio * until dma has been initialized. */ pcm_mute(true); +#ifdef TIME_CODEC + pcmbuf_display_timing(); + fake_pcm_is_playing = false; +#else pcm_play_stop(); +#endif pcm_mute(false); last_chunksize = 0; @@ -318,6 +354,11 @@ /* Force playback. */ void pcmbuf_play_start(void) { +#ifdef TIME_CODEC + (void)pcmbuf_callback; + bytes_played = 0; + fake_pcm_is_playing = true; +#else if (!pcm_is_playing() && pcmbuf_unplayed_bytes) { /** Prevent a very tiny pop from happening by muting audio @@ -329,6 +370,7 @@ /* Now unmute the audio. */ pcm_mute(false); } +#endif } /** @@ -357,10 +399,12 @@ } position_callback = NULL; pcmbuf_event_handler = NULL; +#ifndef TIME_CODEC audiobuffer_pos += copy_n; if (audiobuffer_pos >= pcmbuf_size) audiobuffer_pos -= pcmbuf_size; audiobuffer_free -= copy_n; +#endif audiobuffer_fillpos -= copy_n; } @@ -600,10 +644,18 @@ return false; } +#ifdef TIME_CODEC + if (!fake_pcm_is_playing) { +#else if (!pcm_is_playing()) { +#endif pcmbuf_boost(true); crossfade_active = false; +#ifdef TIME_CODEC + { +#else if (audiobuffer_free < pcmbuf_size - CHUNK_SIZE*4) { +#endif logf("pcm starting"); pcmbuf_play_start(); } Index: apps/pcmbuf.h =================================================================== RCS file: /cvsroot/rockbox/apps/pcmbuf.h,v retrieving revision 1.9 diff -u -r1.9 pcmbuf.h --- apps/pcmbuf.h 27 Jan 2006 16:25:44 -0000 1.9 +++ apps/pcmbuf.h 31 Jan 2006 00:13:47 -0000 @@ -38,6 +38,12 @@ #define pcmbuf_boost(state) do { } while(0) #define pcmbuf_set_boost_mode(state) do { } while(0) #endif +/* Uncomment this to time codecs and be rewarded with a % realtime box when + * you stop playback. Audio playback is disabled with this. */ +#define TIME_CODEC +#ifdef TIME_CODEC +#include "splash.h" +#endif bool pcmbuf_is_lowdata(void); void pcmbuf_flush_audio(void); void pcmbuf_play_start(void); Index: apps/playback.c =================================================================== RCS file: /cvsroot/rockbox/apps/playback.c,v retrieving revision 1.211 diff -u -r1.211 playback.c --- apps/playback.c 28 Jan 2006 12:49:05 -0000 1.211 +++ apps/playback.c 31 Jan 2006 00:13:48 -0000 @@ -215,6 +215,12 @@ static void mp3_set_elapsed(struct mp3entry* id3); int mp3_get_file_pos(void); +#ifdef TIME_CODEC +bool is_filling(void) { + return filling; +} +#endif + static void do_swap(int idx_old, int idx_new) { #ifndef SIMULATOR