From 03b54c29d769705b9f2682d6942521ed36d11852 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Wed, 2 Apr 2008 17:04:59 +0000 Subject: Fix for FS#8601 by pondlife: the disk no longer spins up on a track change when dircache is disabled. This issue was introduced by me in r16019 by adding a call to playlist_peek() in audio_check_new_track(). This fix adds a new playlist API call to work around the problem until we find a better solution. There are also a few simplifications and comment corrections. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16930 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 25 +++++++++---------------- apps/playlist.c | 13 +++++++++++++ apps/playlist.h | 1 + 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'apps') diff --git a/apps/playback.c b/apps/playback.c index 319f55a0ce..10f8fb7ff6 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1910,16 +1910,13 @@ static void audio_rebuffer(void) of the track transition. */ static int audio_check_new_track(void) { - int track_count = audio_track_count(); int old_track_ridx = track_ridx; int i, idx; - int next_playlist_index; bool forward; bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ - /* Now it's good time to send track unbuffer events. */ + /* Now it's good time to send track finish events. */ send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3); - if (dir_skip) { dir_skip = false; @@ -1939,24 +1936,21 @@ static int audio_check_new_track(void) if (new_playlist) ci.new_track = 0; - end_of_playlist = playlist_peek(automatic_skip ? ci.new_track : 0) == NULL; + end_of_playlist = !playlist_checkend(automatic_skip ? ci.new_track : 0); auto_dir_skip = end_of_playlist && global_settings.next_folder; /* If the playlist isn't that big */ - if (automatic_skip && !playlist_check(ci.new_track)) + if (automatic_skip) { - if (ci.new_track >= 0) + while (!playlist_check(ci.new_track)) { - LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED"); - return Q_CODEC_REQUEST_FAILED; - } - /* Find the beginning backward if the user over-skips it */ - while (!playlist_check(++ci.new_track)) if (ci.new_track >= 0) { LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED"); return Q_CODEC_REQUEST_FAILED; } + ci.new_track++; + } } /* Update the playlist */ @@ -1966,9 +1960,7 @@ static int audio_check_new_track(void) { /* If the track change was the result of an auto dir skip, we need to update the playlist now */ - next_playlist_index = playlist_next(ci.new_track); - - if (next_playlist_index < 0) + if (playlist_next(ci.new_track) < 0) { LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED"); return Q_CODEC_REQUEST_FAILED; @@ -2023,6 +2015,7 @@ static int audio_check_new_track(void) } /* If it is not safe to even skip this many track entries */ + int track_count = audio_track_count(); if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK) { ci.new_track = 0; @@ -2041,7 +2034,7 @@ static int audio_check_new_track(void) } /* When skipping backwards, it is possible that we've found a track that's - * buffered, but which is around the track-wrap and therefor not the track + * buffered, but which is around the track-wrap and therefore not the track * we are looking for */ if (!forward) { diff --git a/apps/playlist.c b/apps/playlist.c index 6ab9f3f647..e19690f8ab 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -2480,6 +2480,19 @@ int playlist_start(int start_index, int offset) return 0; } +/* Returns false if 'steps' would pass end of playlist */ +bool playlist_checkend(int steps) +{ + struct playlist_info* playlist = ¤t_playlist; + + int index = get_next_index(playlist, steps, -1); + + if (index < 0 && steps >= 0 && global_settings.repeat_mode == REPEAT_SHUFFLE) + index = get_next_index(playlist, steps, REPEAT_ALL); + + return (index >= 0); +} + /* Returns false if 'steps' is out of bounds, else true */ bool playlist_check(int steps) { diff --git a/apps/playlist.h b/apps/playlist.h index af9a09523f..a3ea225a5d 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -119,6 +119,7 @@ int playlist_resume(void); int playlist_add(const char *filename); int playlist_shuffle(int random_seed, int start_index); int playlist_start(int start_index, int offset); +bool playlist_checkend(int steps); bool playlist_check(int steps); char *playlist_peek(int steps); int playlist_next(int steps); -- cgit v1.2.3