summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-02 17:04:59 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-02 17:04:59 +0000
commit03b54c29d769705b9f2682d6942521ed36d11852 (patch)
tree11bffb177716c7d0b47d2fbf7203ba23374505bf
parent43df8374e53b633caf02cdce8dba16b48875359d (diff)
downloadrockbox-03b54c29d769705b9f2682d6942521ed36d11852.tar.gz
rockbox-03b54c29d769705b9f2682d6942521ed36d11852.zip
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
-rw-r--r--apps/playback.c25
-rw-r--r--apps/playlist.c13
-rw-r--r--apps/playlist.h1
3 files changed, 23 insertions, 16 deletions
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)
1910 of the track transition. */ 1910 of the track transition. */
1911static int audio_check_new_track(void) 1911static int audio_check_new_track(void)
1912{ 1912{
1913 int track_count = audio_track_count();
1914 int old_track_ridx = track_ridx; 1913 int old_track_ridx = track_ridx;
1915 int i, idx; 1914 int i, idx;
1916 int next_playlist_index;
1917 bool forward; 1915 bool forward;
1918 bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ 1916 bool end_of_playlist; /* Temporary flag, not the same as playlist_end */
1919 1917
1920 /* Now it's good time to send track unbuffer events. */ 1918 /* Now it's good time to send track finish events. */
1921 send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3); 1919 send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3);
1922
1923 if (dir_skip) 1920 if (dir_skip)
1924 { 1921 {
1925 dir_skip = false; 1922 dir_skip = false;
@@ -1939,24 +1936,21 @@ static int audio_check_new_track(void)
1939 if (new_playlist) 1936 if (new_playlist)
1940 ci.new_track = 0; 1937 ci.new_track = 0;
1941 1938
1942 end_of_playlist = playlist_peek(automatic_skip ? ci.new_track : 0) == NULL; 1939 end_of_playlist = !playlist_checkend(automatic_skip ? ci.new_track : 0);
1943 auto_dir_skip = end_of_playlist && global_settings.next_folder; 1940 auto_dir_skip = end_of_playlist && global_settings.next_folder;
1944 1941
1945 /* If the playlist isn't that big */ 1942 /* If the playlist isn't that big */
1946 if (automatic_skip && !playlist_check(ci.new_track)) 1943 if (automatic_skip)
1947 { 1944 {
1948 if (ci.new_track >= 0) 1945 while (!playlist_check(ci.new_track))
1949 { 1946 {
1950 LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED");
1951 return Q_CODEC_REQUEST_FAILED;
1952 }
1953 /* Find the beginning backward if the user over-skips it */
1954 while (!playlist_check(++ci.new_track))
1955 if (ci.new_track >= 0) 1947 if (ci.new_track >= 0)
1956 { 1948 {
1957 LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED"); 1949 LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED");
1958 return Q_CODEC_REQUEST_FAILED; 1950 return Q_CODEC_REQUEST_FAILED;
1959 } 1951 }
1952 ci.new_track++;
1953 }
1960 } 1954 }
1961 1955
1962 /* Update the playlist */ 1956 /* Update the playlist */
@@ -1966,9 +1960,7 @@ static int audio_check_new_track(void)
1966 { 1960 {
1967 /* If the track change was the result of an auto dir skip, 1961 /* If the track change was the result of an auto dir skip,
1968 we need to update the playlist now */ 1962 we need to update the playlist now */
1969 next_playlist_index = playlist_next(ci.new_track); 1963 if (playlist_next(ci.new_track) < 0)
1970
1971 if (next_playlist_index < 0)
1972 { 1964 {
1973 LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED"); 1965 LOGFQUEUE("audio >|= codec Q_CODEC_REQUEST_FAILED");
1974 return Q_CODEC_REQUEST_FAILED; 1966 return Q_CODEC_REQUEST_FAILED;
@@ -2023,6 +2015,7 @@ static int audio_check_new_track(void)
2023 } 2015 }
2024 2016
2025 /* If it is not safe to even skip this many track entries */ 2017 /* If it is not safe to even skip this many track entries */
2018 int track_count = audio_track_count();
2026 if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK) 2019 if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK)
2027 { 2020 {
2028 ci.new_track = 0; 2021 ci.new_track = 0;
@@ -2041,7 +2034,7 @@ static int audio_check_new_track(void)
2041 } 2034 }
2042 2035
2043 /* When skipping backwards, it is possible that we've found a track that's 2036 /* When skipping backwards, it is possible that we've found a track that's
2044 * buffered, but which is around the track-wrap and therefor not the track 2037 * buffered, but which is around the track-wrap and therefore not the track
2045 * we are looking for */ 2038 * we are looking for */
2046 if (!forward) 2039 if (!forward)
2047 { 2040 {
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)
2480 return 0; 2480 return 0;
2481} 2481}
2482 2482
2483/* Returns false if 'steps' would pass end of playlist */
2484bool playlist_checkend(int steps)
2485{
2486 struct playlist_info* playlist = &current_playlist;
2487
2488 int index = get_next_index(playlist, steps, -1);
2489
2490 if (index < 0 && steps >= 0 && global_settings.repeat_mode == REPEAT_SHUFFLE)
2491 index = get_next_index(playlist, steps, REPEAT_ALL);
2492
2493 return (index >= 0);
2494}
2495
2483/* Returns false if 'steps' is out of bounds, else true */ 2496/* Returns false if 'steps' is out of bounds, else true */
2484bool playlist_check(int steps) 2497bool playlist_check(int steps)
2485{ 2498{
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);
119int playlist_add(const char *filename); 119int playlist_add(const char *filename);
120int playlist_shuffle(int random_seed, int start_index); 120int playlist_shuffle(int random_seed, int start_index);
121int playlist_start(int start_index, int offset); 121int playlist_start(int start_index, int offset);
122bool playlist_checkend(int steps);
122bool playlist_check(int steps); 123bool playlist_check(int steps);
123char *playlist_peek(int steps); 124char *playlist_peek(int steps);
124int playlist_next(int steps); 125int playlist_next(int steps);