diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-22 06:32:55 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-22 06:32:55 +0000 |
| commit | eab434c416a89a9de30bcca255334eeac97eb433 (patch) | |
| tree | fd13b0eff472cd800d8d7b21babd70725d608de3 | |
| parent | d3cbf8730579002093f003499104a861112d4dc5 (diff) | |
| download | rockbox-eab434c416a89a9de30bcca255334eeac97eb433.zip rockbox-eab434c416a89a9de30bcca255334eeac97eb433.tar.gz rockbox-eab434c416a89a9de30bcca255334eeac97eb433.tar.bz2 rockbox-eab434c416a89a9de30bcca255334eeac97eb433.tar.xz | |
More accurate playback position calculation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7218 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/pcmbuf.c | 4 | ||||
| -rw-r--r-- | apps/playback.c | 5 | ||||
| -rw-r--r-- | firmware/export/pcm_playback.h | 1 | ||||
| -rw-r--r-- | firmware/pcm_playback.c | 7 | ||||
| -rw-r--r-- | uisimulator/common/stubs.c | 5 |
5 files changed, 15 insertions, 7 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index cf6911b..a8769e3 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -202,8 +202,8 @@ unsigned int pcmbuf_get_latency(void) { int latency; - /* This has to be done better. */ - latency = (pcmbuf_size - audiobuffer_free - CHUNK_SIZE)/4 / (44100/1000); + latency = (pcmbuf_unplayed_bytes + pcm_get_bytes_waiting()) + / 4 / (44100/1000); if (latency < 0) latency = 0; diff --git a/apps/playback.c b/apps/playback.c index aadb1e2..7aaff01 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -265,10 +265,7 @@ void codec_set_offset_callback(unsigned int value) if (ci.stop_codec) return ; - /* The 1000 here is a hack. pcmbuf_get_latency() should - * be more accurate - */ - latency = (pcmbuf_get_latency() + 1000) * cur_ti->id3.bitrate / 8; + latency = pcmbuf_get_latency() * cur_ti->id3.bitrate / 8; if (value < latency) { cur_ti->id3.offset = 0; diff --git a/firmware/export/pcm_playback.h b/firmware/export/pcm_playback.h index 6222574..3972e45 100644 --- a/firmware/export/pcm_playback.h +++ b/firmware/export/pcm_playback.h @@ -26,6 +26,7 @@ void pcm_set_frequency(unsigned int frequency); void pcm_play_data(void (*get_more)(unsigned char** start, long* size)); void pcm_calculate_peaks(int *left, int *right); +long pcm_get_bytes_waiting(void); void pcm_play_stop(void); void pcm_play_pause(bool play); diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index 3a68db4..bafbd8c 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -164,7 +164,7 @@ static long calculate_channel_peak_average(int channel, unsigned short *addr, void pcm_calculate_peaks(int *left, int *right) { unsigned short *addr = (unsigned short *)SAR0; - long size = MIN(512, BCR0 / 2); + long size = MIN(512, (BCR0 & 0xffffff) / 2); if (left != NULL) *left = calculate_channel_peak_average(0, addr, size); @@ -222,6 +222,11 @@ void pcm_play_data(void (*get_more)(unsigned char** start, long* size)) uda1380_mute(false); } +long pcm_get_bytes_waiting(void) +{ + return next_size + (BCR0 & 0xffffff); +} + void pcm_play_stop(void) { if (pcm_playing) { diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 4ad89e4..b887fbd 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -66,6 +66,11 @@ void pcm_play_data(void (*get_more)(unsigned char** start, long* size)) playing = true; } +long pcm_get_bytes_waiting(long) +{ + return 0; +} + #if CONFIG_HWCODEC != MASNONE void audio_set_buffer_margin(int seconds) { |