1
0
Fork 0
forked from len0rd/rockbox

Further unify start playback vs. other buffering situations, hopefully fixes some people's audio doesn't start problems

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9553 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Brandon Low 2006-04-07 19:48:48 +00:00
parent ab57025e33
commit 554f206ba1

View file

@ -1363,16 +1363,11 @@ static void audio_play_start(size_t offset)
buf_widx = 0; buf_widx = 0;
filebufused = 0; filebufused = 0;
/* Initialize buffer fill */
pcmbuf_set_boost_mode(true);
fill_bytesleft = AUDIO_DEFAULT_FIRST_LIMIT;
filling = true;
last_peek_offset = -1; last_peek_offset = -1;
if (offset == 0) parameter = -1; if (offset == 0) parameter = -1;
else parameter = offset; else parameter = offset;
/* Request initial buffer fill */
queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, (void *)parameter); queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, (void *)parameter);
} }
@ -1408,7 +1403,7 @@ static void generate_postbuffer_events(void)
} }
} }
static void initialize_buffer_fill(void) static void initialize_buffer_fill(bool start_play)
{ {
int cur_idx, i; int cur_idx, i;
@ -1419,13 +1414,11 @@ static void initialize_buffer_fill(void)
/* 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());
cur_ti->start_pos = ci.curpos;
pcmbuf_set_boost_mode(true); pcmbuf_set_boost_mode(true);
filling = true; if (!start_play) {
cur_ti->start_pos = ci.curpos;
/* FIXME: This should be recalculated more often than once per fill cycle. /* FIXME: Should be recalculated more often than once per fill cycle.
* This way we only fill up to the read point when filling started. */ * This way we only fill up to the read point when filling started. */
fill_bytesleft = filebuflen - filebufused; fill_bytesleft = filebuflen - filebufused;
@ -1449,18 +1442,22 @@ static void initialize_buffer_fill(void)
/* Mark all buffered entries null (not metadata for next track). */ /* Mark all buffered entries null (not metadata for next track). */
audio_clear_track_entries(true); audio_clear_track_entries(true);
} else {
fill_bytesleft = AUDIO_DEFAULT_FIRST_LIMIT;
}
filling = true;
} }
static void audio_fill_file_buffer(long parameter) static void audio_fill_file_buffer(bool start_play, size_t offset)
{ {
size_t offset = parameter < 0?0:parameter; if (!filling && !start_play)
bool start_play = (bool)parameter;
if (!filling)
if (ci.stop_codec || ci.reload_codec || playlist_end) if (ci.stop_codec || ci.reload_codec || playlist_end)
return; return;
mutex_lock(&mutex_bufferfill); mutex_lock(&mutex_bufferfill);
initialize_buffer_fill(); initialize_buffer_fill(start_play);
mutex_unlock(&mutex_bufferfill); mutex_unlock(&mutex_bufferfill);
/* If we have a partially buffered track, continue loading, otherwise /* If we have a partially buffered track, continue loading, otherwise
@ -1805,12 +1802,12 @@ void audio_thread(void)
} }
} }
else else
queue_wait(&audio_queue, &ev); queue_wait_w_tmo(&audio_queue, &ev, HZ);
switch (ev.id) { switch (ev.id) {
case Q_AUDIO_FILL_BUFFER: case Q_AUDIO_FILL_BUFFER:
audio_fill_file_buffer((long)ev.data); audio_fill_file_buffer((bool)ev.data,abs((long)ev.data));
break; break;
case Q_AUDIO_PLAY: case Q_AUDIO_PLAY:
/* Don't start playing immediately if user is skipping tracks /* Don't start playing immediately if user is skipping tracks
@ -1845,14 +1842,7 @@ void audio_thread(void)
yield(); yield();
audio_play_start((size_t)ev.data); audio_play_start((size_t)ev.data);
playlist_update_resume_info(audio_current_track());
/* If there are no tracks in the playlist, then the playlist
was empty or none of the filenames were valid. No point
in playing an empty playlist. */
if (playlist_amount() == 0) {
audio_stop_playback(false);
}
break ; break ;
case Q_AUDIO_STOP: case Q_AUDIO_STOP: