forked from len0rd/rockbox
Fixed a problem that caused playback to stutter when changing tracks
fast. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7157 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bb0c7751f0
commit
34a25a6a3b
2 changed files with 13 additions and 12 deletions
|
|
@ -228,6 +228,7 @@ bool pcmbuf_crossfade_init(void)
|
||||||
{
|
{
|
||||||
if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 8 || !crossfade_enabled
|
if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 8 || !crossfade_enabled
|
||||||
|| crossfade_active || crossfade_init) {
|
|| crossfade_active || crossfade_init) {
|
||||||
|
pcmbuf_flush_audio();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logf("pcmbuf_crossfade_init");
|
logf("pcmbuf_crossfade_init");
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,12 @@ int codecbufused;
|
||||||
static volatile int buf_ridx;
|
static volatile int buf_ridx;
|
||||||
static volatile int buf_widx;
|
static volatile int buf_widx;
|
||||||
|
|
||||||
|
/* Step count to the next unbuffered track. */
|
||||||
static int last_peek_offset;
|
static int last_peek_offset;
|
||||||
|
|
||||||
|
/* Index of the last buffered track. */
|
||||||
|
static int last_index;
|
||||||
|
|
||||||
/* Track information (count in file buffer, read/write indexes for
|
/* Track information (count in file buffer, read/write indexes for
|
||||||
track ring structure. */
|
track ring structure. */
|
||||||
int track_count;
|
int track_count;
|
||||||
|
|
@ -817,6 +821,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
|
||||||
if (tracks[track_widx].filesize != 0)
|
if (tracks[track_widx].filesize != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
last_index = playlist_get_display_index();
|
||||||
|
|
||||||
/* Get track name from current playlist read position. */
|
/* Get track name from current playlist read position. */
|
||||||
logf("Buffering track:%d/%d", track_widx, track_ridx);
|
logf("Buffering track:%d/%d", track_widx, track_ridx);
|
||||||
trackname = playlist_peek(peek_offset);
|
trackname = playlist_peek(peek_offset);
|
||||||
|
|
@ -1368,9 +1374,6 @@ static void initiate_track_change(int peek_index)
|
||||||
playlist_next(peek_index);
|
playlist_next(peek_index);
|
||||||
queue_post(&audio_queue, AUDIO_PLAY, 0);
|
queue_post(&audio_queue, AUDIO_PLAY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!pcmbuf_crossfade_init())
|
|
||||||
pcmbuf_flush_audio();
|
|
||||||
|
|
||||||
codec_track_changed();
|
codec_track_changed();
|
||||||
}
|
}
|
||||||
|
|
@ -1389,13 +1392,16 @@ void audio_thread(void)
|
||||||
queue_wait_w_tmo(&audio_queue, &ev, 0);
|
queue_wait_w_tmo(&audio_queue, &ev, 0);
|
||||||
switch (ev.id) {
|
switch (ev.id) {
|
||||||
case AUDIO_PLAY:
|
case AUDIO_PLAY:
|
||||||
|
/* Refuse to start playback if we are already playing
|
||||||
|
the requested track. */
|
||||||
|
if (last_index == playlist_get_display_index() && playing)
|
||||||
|
break ;
|
||||||
logf("starting...");
|
logf("starting...");
|
||||||
playing = true;
|
playing = true;
|
||||||
ci.stop_codec = true;
|
ci.stop_codec = true;
|
||||||
ci.reload_codec = false;
|
ci.reload_codec = false;
|
||||||
ci.seek_time = 0;
|
ci.seek_time = 0;
|
||||||
if (!pcmbuf_crossfade_init() && !pcmbuf_is_crossfade_active())
|
pcmbuf_crossfade_init();
|
||||||
pcmbuf_flush_audio();
|
|
||||||
audio_play_start((int)ev.data);
|
audio_play_start((int)ev.data);
|
||||||
playlist_update_resume_info(audio_current_track());
|
playlist_update_resume_info(audio_current_track());
|
||||||
break ;
|
break ;
|
||||||
|
|
@ -1570,13 +1576,7 @@ bool audio_has_changed_track(void)
|
||||||
void audio_play(int offset)
|
void audio_play(int offset)
|
||||||
{
|
{
|
||||||
logf("audio_play");
|
logf("audio_play");
|
||||||
ci.stop_codec = true;
|
last_index = -1;
|
||||||
if (!pcmbuf_crossfade_init())
|
|
||||||
pcmbuf_flush_audio();
|
|
||||||
codec_track_changed();
|
|
||||||
|
|
||||||
pcm_play_pause(true);
|
|
||||||
paused = false;
|
|
||||||
queue_post(&audio_queue, AUDIO_PLAY, (void *)offset);
|
queue_post(&audio_queue, AUDIO_PLAY, (void *)offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue