summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2002-10-06 05:50:41 +0000
committerHardeep Sidhu <dyp@pobox.com>2002-10-06 05:50:41 +0000
commit83611fe8c32d99bb463358f5ec8e0ebe466f1f42 (patch)
treeb91fa4d1e70adbccb10978b64db3c5d721b4b71c
parentac2e0f1c3286edff9027404d4d15bc5e2445a4a2 (diff)
downloadrockbox-83611fe8c32d99bb463358f5ec8e0ebe466f1f42.zip
rockbox-83611fe8c32d99bb463358f5ec8e0ebe466f1f42.tar.gz
rockbox-83611fe8c32d99bb463358f5ec8e0ebe466f1f42.tar.bz2
rockbox-83611fe8c32d99bb463358f5ec8e0ebe466f1f42.tar.xz
Store the first index of the playlist and use it when calculating the next index in repeat off mode so that shuffled dirplay works correctly when "play selected" is enabled.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2514 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c20
-rw-r--r--apps/playlist.h8
-rw-r--r--apps/settings.c10
-rw-r--r--apps/settings.h1
-rw-r--r--apps/tree.c15
5 files changed, 38 insertions, 16 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 038e710..23c3f5d 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -68,23 +68,30 @@ int playlist_add(char *filename)
static int get_next_index(int steps)
{
- int next_index = -1;
+ int current_index = playlist.index;
+ int next_index = -1;
switch (global_settings.repeat_mode)
{
case REPEAT_OFF:
- next_index = playlist.index+steps;
+ if (current_index < playlist.first_index)
+ current_index += playlist.amount;
+ current_index -= playlist.first_index;
+
+ next_index = current_index+steps;
if ((next_index < 0) || (next_index >= playlist.amount))
next_index = -1;
+ else
+ next_index = (next_index+playlist.first_index)%playlist.amount;
break;
case REPEAT_ONE:
- next_index = playlist.index;
+ next_index = current_index;
break;
case REPEAT_ALL:
default:
- next_index = (playlist.index+steps) % playlist.amount;
+ next_index = (current_index+steps) % playlist.amount;
while (next_index < 0)
next_index += playlist.amount;
break;
@@ -212,13 +219,15 @@ int play_list(char *dir, /* "current directory" */
bool shuffled_index, /* if TRUE the specified index is for the
playlist AFTER the shuffle */
int start_offset, /* offset in the file */
- int random_seed ) /* used for shuffling */
+ int random_seed, /* used for shuffling */
+ int first_index ) /* first index of playlist */
{
char *sep="";
int dirlen;
empty_playlist();
playlist.index = start_index;
+ playlist.first_index = first_index;
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
@@ -283,6 +292,7 @@ int play_list(char *dir, /* "current directory" */
if(seek_pos == playlist.indices[i]) {
/* here's the start song! yiepee! */
playlist.index = i;
+ playlist.first_index = i;
break; /* now stop searching */
}
}
diff --git a/apps/playlist.h b/apps/playlist.h
index a18240d..9f66b7f4 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -28,10 +28,11 @@
struct playlist_info
{
- char filename[MAX_PATH]; /* path name of m3u playlist on disk */
+ char filename[MAX_PATH]; /* path name of m3u playlist on disk */
int dirlen; /* Length of the path to the playlist file */
int indices[MAX_PLAYLIST_SIZE]; /* array of indices */
- int index; /* index of *NEXT* track to play */
+ int index; /* index of current playing track */
+ int first_index; /* index of first song in playlist */
int seed; /* random seed */
int amount; /* number of tracks in the index */
bool in_ram; /* True if the playlist is RAM-based */
@@ -41,7 +42,8 @@ extern struct playlist_info playlist;
extern bool playlist_shuffle;
int play_list(char *dir, char *file, int start_index,
- bool shuffled_index, int start_offset, int random_seed );
+ bool shuffled_index, int start_offset,
+ int random_seed, int first_index);
char* playlist_peek(int steps);
int playlist_next(int steps);
void randomise_playlist( unsigned int seed );
diff --git a/apps/settings.c b/apps/settings.c
index 0ba72df..dab44fe 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -112,6 +112,7 @@ modified unless the header & checksum test fails.
Rest of config block, only saved to disk:
+0xF4 (int) Playlist first index
0xF8 (int) Playlist shuffle seed
0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u)
@@ -316,9 +317,11 @@ int settings_save( void )
config_block[0x1e] = (unsigned char)global_settings.peak_meter_release;
config_block[0x1f] = (unsigned char)global_settings.repeat_mode;
+ memcpy(&config_block[0x24], &global_settings.total_uptime, 4);
+
+ memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4);
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
- memcpy(&config_block[0x24], &global_settings.total_uptime, 4);
strncpy(&config_block[0xFC], global_settings.resume_file, MAX_PATH);
DEBUGF("+Resume file %s\n",global_settings.resume_file);
@@ -471,11 +474,12 @@ void settings_load(void)
if (config_block[0x1f] != 0xFF)
global_settings.repeat_mode = config_block[0x1f];
- memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
-
if (config_block[0x24] != 0xFF)
memcpy(&global_settings.total_uptime, &config_block[0x24], 4);
+ memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
+ memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
+
strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH);
global_settings.resume_file[MAX_PATH]=0;
}
diff --git a/apps/settings.h b/apps/settings.h
index b30d8aa..d64d00e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -73,6 +73,7 @@ struct user_settings
int resume_index; /* index in playlist (-1 for no active resume) */
int resume_offset; /* byte offset in mp3 file */
int resume_seed; /* random seed for playlist shuffle */
+ int resume_first_index; /* first index of playlist */
unsigned char resume_file[MAX_PATH+1]; /* playlist name (or dir) */
/* misc options */
diff --git a/apps/tree.c b/apps/tree.c
index 653b6af..f4a49a9 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -505,7 +505,8 @@ void start_resume(void)
global_settings.resume_index,
true, /* the index is AFTER shuffle */
global_settings.resume_offset,
- global_settings.resume_seed );
+ global_settings.resume_seed,
+ global_settings.resume_first_index);
*slash='/';
}
else {
@@ -523,7 +524,8 @@ void start_resume(void)
global_settings.resume_index,
true,
global_settings.resume_offset,
- global_settings.resume_seed );
+ global_settings.resume_seed,
+ global_settings.resume_first_index);
}
}
else {
@@ -541,7 +543,8 @@ void start_resume(void)
global_settings.resume_index,
true,
global_settings.resume_offset,
- global_settings.resume_seed);
+ global_settings.resume_seed,
+ global_settings.resume_first_index);
}
status_set_playmode(STATUS_PLAY);
@@ -775,7 +778,8 @@ bool dirbrowse(char *root)
snprintf(global_settings.resume_file,
MAX_PATH, "%s/%s",
currdir, file->name);
- play_list(currdir, file->name, 0, false, 0, seed );
+ play_list(currdir, file->name, 0, false, 0,
+ seed, 0);
start_index = 0;
play = true;
break;
@@ -790,7 +794,7 @@ bool dirbrowse(char *root)
the (shuffled) list and stor that */
start_index = play_list(currdir, NULL,
start_index, false,
- 0, seed);
+ 0, seed, 0);
play = true;
break;
@@ -872,6 +876,7 @@ bool dirbrowse(char *root)
shuffled list in case shuffle is enabled */
global_settings.resume_index = start_index;
global_settings.resume_offset = 0;
+ global_settings.resume_first_index = start_index;
global_settings.resume_seed = seed;
settings_save();
}