diff options
| author | Brandon Low <lostlogic@rockbox.org> | 2006-04-07 19:48:48 +0000 |
|---|---|---|
| committer | Brandon Low <lostlogic@rockbox.org> | 2006-04-07 19:48:48 +0000 |
| commit | 554f206ba15c0c7ce18b75f031967e21c7eebdfd (patch) | |
| tree | 6a42ebfb6b6d013263269aeb3740f29e6ca4cf68 | |
| parent | ab57025e33febd268c43c605b084a62c0ae86fa7 (diff) | |
| download | rockbox-554f206ba15c0c7ce18b75f031967e21c7eebdfd.zip rockbox-554f206ba15c0c7ce18b75f031967e21c7eebdfd.tar.gz rockbox-554f206ba15c0c7ce18b75f031967e21c7eebdfd.tar.bz2 rockbox-554f206ba15c0c7ce18b75f031967e21c7eebdfd.tar.xz | |
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
| -rw-r--r-- | apps/playback.c | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/apps/playback.c b/apps/playback.c index 4d8d9b0..04b7da9 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1363,16 +1363,11 @@ static void audio_play_start(size_t offset) buf_widx = 0; filebufused = 0; - /* Initialize buffer fill */ - pcmbuf_set_boost_mode(true); - fill_bytesleft = AUDIO_DEFAULT_FIRST_LIMIT; - filling = true; last_peek_offset = -1; if (offset == 0) parameter = -1; else parameter = offset; - /* Request initial buffer fill */ 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; @@ -1419,48 +1414,50 @@ static void initialize_buffer_fill(void) /* Save the current resume position once. */ playlist_update_resume_info(audio_current_track()); - cur_ti->start_pos = ci.curpos; - pcmbuf_set_boost_mode(true); - filling = true; + if (!start_play) { + cur_ti->start_pos = ci.curpos; + /* FIXME: Should be recalculated more often than once per fill cycle. + * This way we only fill up to the read point when filling started. */ + fill_bytesleft = filebuflen - filebufused; - /* FIXME: This should be recalculated more often than once per fill cycle. - * This way we only fill up to the read point when filling started. */ - fill_bytesleft = filebuflen - filebufused; + /* Calculate real track count after throwing away old tracks. */ + cur_idx = track_ridx; + for (i = 0; i < track_count; i++) { + if (cur_idx == track_widx) + break ; - /* Calculate real track count after throwing away old tracks. */ - cur_idx = track_ridx; - for (i = 0; i < track_count; i++) { - if (cur_idx == track_widx) - break ; + if (++cur_idx >= MAX_TRACK) + cur_idx = 0; + } - if (++cur_idx >= MAX_TRACK) - cur_idx = 0; - } + track_count = i; + if (tracks[track_widx].filesize == 0) { + if (--track_widx < 0) + track_widx = MAX_TRACK - 1; + } else { + track_count++; + } - track_count = i; - if (tracks[track_widx].filesize == 0) { - if (--track_widx < 0) - track_widx = MAX_TRACK - 1; + /* Mark all buffered entries null (not metadata for next track). */ + audio_clear_track_entries(true); } else { - track_count++; + fill_bytesleft = AUDIO_DEFAULT_FIRST_LIMIT; } - /* Mark all buffered entries null (not metadata for next track). */ - audio_clear_track_entries(true); + 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; - bool start_play = (bool)parameter; - if (!filling) + if (!filling && !start_play) if (ci.stop_codec || ci.reload_codec || playlist_end) return; mutex_lock(&mutex_bufferfill); - initialize_buffer_fill(); + initialize_buffer_fill(start_play); mutex_unlock(&mutex_bufferfill); /* If we have a partially buffered track, continue loading, otherwise @@ -1805,12 +1802,12 @@ void audio_thread(void) } } else - queue_wait(&audio_queue, &ev); + queue_wait_w_tmo(&audio_queue, &ev, HZ); switch (ev.id) { case Q_AUDIO_FILL_BUFFER: - audio_fill_file_buffer((long)ev.data); + audio_fill_file_buffer((bool)ev.data,abs((long)ev.data)); break; case Q_AUDIO_PLAY: /* Don't start playing immediately if user is skipping tracks @@ -1845,14 +1842,7 @@ void audio_thread(void) yield(); 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 ; case Q_AUDIO_STOP: |