forked from len0rd/rockbox
More accurate playback position calculation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7218 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d3cbf87305
commit
eab434c416
5 changed files with 15 additions and 7 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue