1
0
Fork 0
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:
Miika Pekkarinen 2005-07-15 16:42:01 +00:00
parent bb0c7751f0
commit 34a25a6a3b
2 changed files with 13 additions and 12 deletions

View file

@ -228,6 +228,7 @@ bool pcmbuf_crossfade_init(void)
{
if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 8 || !crossfade_enabled
|| crossfade_active || crossfade_init) {
pcmbuf_flush_audio();
return false;
}
logf("pcmbuf_crossfade_init");

View file

@ -131,8 +131,12 @@ int codecbufused;
static volatile int buf_ridx;
static volatile int buf_widx;
/* Step count to the next unbuffered track. */
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 ring structure. */
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)
return false;
last_index = playlist_get_display_index();
/* Get track name from current playlist read position. */
logf("Buffering track:%d/%d", track_widx, track_ridx);
trackname = playlist_peek(peek_offset);
@ -1368,9 +1374,6 @@ static void initiate_track_change(int peek_index)
playlist_next(peek_index);
queue_post(&audio_queue, AUDIO_PLAY, 0);
}
else if (!pcmbuf_crossfade_init())
pcmbuf_flush_audio();
codec_track_changed();
}
@ -1389,13 +1392,16 @@ void audio_thread(void)
queue_wait_w_tmo(&audio_queue, &ev, 0);
switch (ev.id) {
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...");
playing = true;
ci.stop_codec = true;
ci.reload_codec = false;
ci.seek_time = 0;
if (!pcmbuf_crossfade_init() && !pcmbuf_is_crossfade_active())
pcmbuf_flush_audio();
pcmbuf_crossfade_init();
audio_play_start((int)ev.data);
playlist_update_resume_info(audio_current_track());
break ;
@ -1570,13 +1576,7 @@ bool audio_has_changed_track(void)
void audio_play(int offset)
{
logf("audio_play");
ci.stop_codec = true;
if (!pcmbuf_crossfade_init())
pcmbuf_flush_audio();
codec_track_changed();
pcm_play_pause(true);
paused = false;
last_index = -1;
queue_post(&audio_queue, AUDIO_PLAY, (void *)offset);
}