forked from len0rd/rockbox
Ensure that the buffer doesn't get out of sync on rebuffer track changes. Remove the concept of pcmuf_boost_mode as it doesn't seem necessary, and adds an unnecessary way for the CPU to stay boosted.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9646 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0c915510c6
commit
0744e760cb
3 changed files with 31 additions and 26 deletions
|
|
@ -109,13 +109,11 @@ static void pcmbuf_flush_audio(void);
|
||||||
static void pcmbuf_under_watermark(void);
|
static void pcmbuf_under_watermark(void);
|
||||||
|
|
||||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
|
||||||
static bool boost_mode;
|
|
||||||
|
|
||||||
void pcmbuf_boost(bool state)
|
void pcmbuf_boost(bool state)
|
||||||
{
|
{
|
||||||
static bool boost_state = false;
|
static bool boost_state = false;
|
||||||
|
|
||||||
if (crossfade_init || crossfade_active || boost_mode)
|
if (crossfade_init || crossfade_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state != boost_state) {
|
if (state != boost_state) {
|
||||||
|
|
@ -123,13 +121,6 @@ void pcmbuf_boost(bool state)
|
||||||
boost_state = state;
|
boost_state = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcmbuf_set_boost_mode(bool state)
|
|
||||||
{
|
|
||||||
if (state)
|
|
||||||
pcmbuf_boost(true);
|
|
||||||
boost_mode = state;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CALL_IF_EXISTS(function, args...) if (function) function(args)
|
#define CALL_IF_EXISTS(function, args...) if (function) function(args)
|
||||||
|
|
@ -314,7 +305,6 @@ void pcmbuf_play_stop(void)
|
||||||
crossfade_init = false;
|
crossfade_init = false;
|
||||||
crossfade_active = false;
|
crossfade_active = false;
|
||||||
|
|
||||||
pcmbuf_set_boost_mode(false);
|
|
||||||
pcmbuf_boost(false);
|
pcmbuf_boost(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -664,6 +664,8 @@ static bool buffer_wind_forward(bool require_codec,
|
||||||
/* Then collect all data from tracks in between them */
|
/* Then collect all data from tracks in between them */
|
||||||
amount += buffer_count_tracks(old_track_ridx, new_track_ridx);
|
amount += buffer_count_tracks(old_track_ridx, new_track_ridx);
|
||||||
|
|
||||||
|
logf("bwf:%ldB",amount);
|
||||||
|
|
||||||
/* Wind the buffer to the beginning of the target track or its codec */
|
/* Wind the buffer to the beginning of the target track or its codec */
|
||||||
buf_ridx += amount;
|
buf_ridx += amount;
|
||||||
filebufused -= amount;
|
filebufused -= amount;
|
||||||
|
|
@ -684,7 +686,7 @@ static bool buffer_wind_backward(bool require_codec,
|
||||||
/* Start with the previously playing track's data and our data */
|
/* Start with the previously playing track's data and our data */
|
||||||
size_t amount = ci.curpos;
|
size_t amount = ci.curpos;
|
||||||
|
|
||||||
/* If we're not just resetting the current_track */
|
/* If we're not just resetting the current track */
|
||||||
if (new_track_ridx != old_track_ridx)
|
if (new_track_ridx != old_track_ridx)
|
||||||
{
|
{
|
||||||
/* Need to wind to before the old track's codec and our filesize */
|
/* Need to wind to before the old track's codec and our filesize */
|
||||||
|
|
@ -717,6 +719,8 @@ static bool buffer_wind_backward(bool require_codec,
|
||||||
if (amount > buf_back)
|
if (amount > buf_back)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
logf("bwb:%ldB",amount);
|
||||||
|
|
||||||
/* Check and handle buffer wrapping */
|
/* Check and handle buffer wrapping */
|
||||||
if (amount > buf_ridx)
|
if (amount > buf_ridx)
|
||||||
buf_ridx += filebuflen;
|
buf_ridx += filebuflen;
|
||||||
|
|
@ -795,8 +799,9 @@ static void audio_check_new_track(bool require_codec)
|
||||||
else if (track_ridx < 0)
|
else if (track_ridx < 0)
|
||||||
track_ridx += MAX_TRACK;
|
track_ridx += MAX_TRACK;
|
||||||
|
|
||||||
/* Move to the new track */
|
/* Save the old track */
|
||||||
prev_ti = cur_ti;
|
prev_ti = cur_ti;
|
||||||
|
/* Move to the new track */
|
||||||
cur_ti = &tracks[track_ridx];
|
cur_ti = &tracks[track_ridx];
|
||||||
|
|
||||||
track_changed = manual_skip;
|
track_changed = manual_skip;
|
||||||
|
|
@ -805,8 +810,7 @@ static void audio_check_new_track(bool require_codec)
|
||||||
if (new_track >= track_count || new_track <= track_count - MAX_TRACK)
|
if (new_track >= track_count || new_track <= track_count - MAX_TRACK)
|
||||||
audio_rebuffer();
|
audio_rebuffer();
|
||||||
/* If the target track is clearly not in memory */
|
/* If the target track is clearly not in memory */
|
||||||
else if (tracks[track_ridx].filesize == 0 ||
|
else if (cur_ti->filesize == 0 || !cur_ti->taginfo_ready)
|
||||||
!tracks[track_ridx].taginfo_ready)
|
|
||||||
audio_rebuffer();
|
audio_rebuffer();
|
||||||
/* The track may be in memory, see if it really is */
|
/* The track may be in memory, see if it really is */
|
||||||
else if (new_track > 0)
|
else if (new_track > 0)
|
||||||
|
|
@ -844,7 +848,7 @@ static void audio_check_new_track(bool require_codec)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tracks[track_ridx].taginfo_ready = false;
|
cur_ti->taginfo_ready = false;
|
||||||
audio_rebuffer();
|
audio_rebuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1213,6 +1217,16 @@ static void codec_discard_codec_callback(void)
|
||||||
if (buf_ridx >= filebuflen)
|
if (buf_ridx >= filebuflen)
|
||||||
buf_ridx -= filebuflen;
|
buf_ridx -= filebuflen;
|
||||||
}
|
}
|
||||||
|
/* Check if a buffer desync has happened, and log it */
|
||||||
|
if (buf_ridx != cur_ti->buf_idx)
|
||||||
|
{
|
||||||
|
logf("Buf off:%d/%d", buf_ridx, cur_ti->buf_idx);
|
||||||
|
buf_ridx = cur_ti->buf_idx;
|
||||||
|
filebufused = track_widx;
|
||||||
|
if (track_widx < track_ridx)
|
||||||
|
filebufused += filebuflen;
|
||||||
|
filebufused -= track_ridx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool loadcodec(bool start_play)
|
static bool loadcodec(bool start_play)
|
||||||
|
|
@ -1283,10 +1297,11 @@ static bool loadcodec(bool start_play)
|
||||||
if (start_play)
|
if (start_play)
|
||||||
{
|
{
|
||||||
/* Load the codec directly from disk and save some memory. */
|
/* Load the codec directly from disk and save some memory. */
|
||||||
cur_ti = &tracks[track_widx];
|
track_ridx = track_widx;
|
||||||
|
cur_ti = &tracks[track_ridx];
|
||||||
ci.filesize = cur_ti->filesize;
|
ci.filesize = cur_ti->filesize;
|
||||||
ci.id3 = (struct mp3entry *)&cur_ti->id3;
|
ci.id3 = &cur_ti->id3;
|
||||||
ci.taginfo_ready = (bool *)&cur_ti->taginfo_ready;
|
ci.taginfo_ready = &cur_ti->taginfo_ready;
|
||||||
ci.curpos = 0;
|
ci.curpos = 0;
|
||||||
playing = true;
|
playing = true;
|
||||||
logf("Starting codec");
|
logf("Starting codec");
|
||||||
|
|
@ -1535,7 +1550,8 @@ static bool audio_load_track(int offset, bool start_play)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logf("arf:%s", trackname);
|
logf("alt:%s", trackname);
|
||||||
|
tracks[track_widx].buf_idx = buf_widx;
|
||||||
audio_read_file();
|
audio_read_file();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1599,7 +1615,6 @@ static void audio_stop_playback(void)
|
||||||
filling = false;
|
filling = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
stop_codec_flush();
|
stop_codec_flush();
|
||||||
pcmbuf_set_boost_mode(false);
|
|
||||||
if (current_fd >= 0) {
|
if (current_fd >= 0) {
|
||||||
close(current_fd);
|
close(current_fd);
|
||||||
current_fd = -1;
|
current_fd = -1;
|
||||||
|
|
@ -1704,12 +1719,11 @@ static void initialize_buffer_fill(bool clear_tracks, bool short_fill)
|
||||||
if (filling)
|
if (filling)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
logf("Starting buffer fill");
|
||||||
|
|
||||||
if (clear_tracks)
|
if (clear_tracks)
|
||||||
audio_clear_track_entries(false);
|
audio_clear_track_entries(false);
|
||||||
|
|
||||||
logf("Starting buffer fill");
|
|
||||||
pcmbuf_set_boost_mode(true);
|
|
||||||
|
|
||||||
/* Save the current resume position once. */
|
/* Save the current resume position once. */
|
||||||
playlist_update_resume_info(audio_current_track());
|
playlist_update_resume_info(audio_current_track());
|
||||||
|
|
||||||
|
|
@ -1736,7 +1750,6 @@ static void audio_fill_file_buffer(
|
||||||
generate_postbuffer_events();
|
generate_postbuffer_events();
|
||||||
filling = false;
|
filling = false;
|
||||||
filling_short = false;
|
filling_short = false;
|
||||||
pcmbuf_set_boost_mode(false);
|
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
if (playing)
|
if (playing)
|
||||||
|
|
@ -2080,7 +2093,8 @@ static void reset_buffer(void)
|
||||||
iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE];
|
iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE];
|
||||||
#endif
|
#endif
|
||||||
dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
|
dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
|
||||||
dram_buf[1] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE];
|
dram_buf[1] =
|
||||||
|
(unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ struct track_info {
|
||||||
size_t codecsize; /* Codec length in bytes */
|
size_t codecsize; /* Codec length in bytes */
|
||||||
bool has_codec; /* Does this track have a codec on the buffer */
|
bool has_codec; /* Does this track have a codec on the buffer */
|
||||||
|
|
||||||
|
size_t buf_idx; /* Pointer to the track's buffer */
|
||||||
size_t filerem; /* Remaining bytes of file NOT in buffer */
|
size_t filerem; /* Remaining bytes of file NOT in buffer */
|
||||||
size_t filesize; /* File total length */
|
size_t filesize; /* File total length */
|
||||||
size_t start_pos; /* Position to first bytes of file in buffer */
|
size_t start_pos; /* Position to first bytes of file in buffer */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue