From 9d860e19d2aedc9dc672a037b7c2de728dd6477e Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Fri, 11 Apr 2003 00:29:15 +0000 Subject: Better handling of next/prev git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3528 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 8 ++++++++ apps/playlist.h | 1 + apps/wps.c | 2 -- firmware/mpeg.c | 7 +++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 165c13847b..ebe82cc457 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -378,6 +378,14 @@ int playlist_next(int steps) return index; } +/* Returns false if 'steps' is out of bounds, else true */ +bool playlist_check(int steps) +{ + bool queue; + int index = get_next_index(steps, &queue); + return (index >= 0); +} + char* playlist_peek(int steps) { int seek; diff --git a/apps/playlist.h b/apps/playlist.h index 57a23f2a8f..ea77886bb7 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -55,6 +55,7 @@ int play_list(char *dir, char *file, int start_index, char* playlist_peek(int steps); char* playlist_name(char *name, int name_size); int playlist_next(int steps); +bool playlist_check(int steps); void randomise_playlist( unsigned int seed ); void sort_playlist(bool start_current); void add_indices_to_playlist(void); diff --git a/apps/wps.c b/apps/wps.c index fded51fe13..0fbe8d713e 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -915,7 +915,6 @@ int wps_show(void) break; #endif if (!id3 || (id3->elapsed < 3*1000)) { - mpeg_stop(); mpeg_prev(); } else { @@ -935,7 +934,6 @@ int wps_show(void) if ( lastbutton != BUTTON_RIGHT ) break; #endif - mpeg_stop(); mpeg_next(); break; diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 718d5c4c62..015d6a9e2a 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -77,6 +77,7 @@ static enum #endif extern char* playlist_peek(int steps); +extern bool playlist_check(int steps); extern int playlist_next(int steps); extern int playlist_amount(void); extern void update_file_pos( int id, int pos ); @@ -1415,7 +1416,7 @@ static void mpeg_thread(void) } } else { - if (!playlist_peek(1)) + if (!playlist_check(1)) break; /* stop the current stream */ @@ -1450,8 +1451,10 @@ static void mpeg_thread(void) case MPEG_PREV: { DEBUGF("MPEG_PREV\n"); - if (!playlist_peek(-1)) + + if (!playlist_check(-1)) break; + /* stop the current stream */ play_pending = false; playing = false; -- cgit v1.2.3