mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
Relative path playlist patch by Mat Pritchard
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1342 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
75447f6d41
commit
6b91b7ea57
3 changed files with 24 additions and 19 deletions
|
|
@ -33,14 +33,15 @@
|
||||||
|
|
||||||
playlist_info_t playlist;
|
playlist_info_t playlist;
|
||||||
|
|
||||||
char now_playing[256];
|
char now_playing[MAX_PATH+1];
|
||||||
|
|
||||||
char* playlist_next(int steps)
|
char* playlist_next(int steps, char *dirname)
|
||||||
{
|
{
|
||||||
int seek;
|
int seek;
|
||||||
int max;
|
int max;
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
|
char buf[MAX_PATH+1];
|
||||||
|
|
||||||
playlist.index = (playlist.index+steps) % playlist.amount;
|
playlist.index = (playlist.index+steps) % playlist.amount;
|
||||||
seek = playlist.indices[playlist.index];
|
seek = playlist.indices[playlist.index];
|
||||||
|
|
@ -48,36 +49,40 @@ char* playlist_next(int steps)
|
||||||
fd = open(playlist.filename, O_RDONLY);
|
fd = open(playlist.filename, O_RDONLY);
|
||||||
if(-1 != fd) {
|
if(-1 != fd) {
|
||||||
lseek(fd, seek, SEEK_SET);
|
lseek(fd, seek, SEEK_SET);
|
||||||
max = read(fd, now_playing+1, sizeof(now_playing)-1);
|
max = read(fd, buf, sizeof(buf)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* Zero-terminate the file name */
|
/* Zero-terminate the file name */
|
||||||
seek=0;
|
seek=0;
|
||||||
while((now_playing[seek] != '\n') &&
|
while((buf[seek] != '\n') &&
|
||||||
(now_playing[seek] != '\r') &&
|
(buf[seek] != '\r') &&
|
||||||
(seek < max))
|
(seek < max))
|
||||||
seek++;
|
seek++;
|
||||||
|
|
||||||
/* Now work back killing white space */
|
/* Now work back killing white space */
|
||||||
while((now_playing[seek-1] == ' ') ||
|
while((buf[seek-1] == ' ') ||
|
||||||
(now_playing[seek-1] == '\t'))
|
(buf[seek-1] == '\t'))
|
||||||
seek--;
|
seek--;
|
||||||
|
|
||||||
now_playing[seek]=0;
|
buf[seek]=0;
|
||||||
|
|
||||||
/* replace backslashes with forward slashes */
|
/* replace backslashes with forward slashes */
|
||||||
for ( i=1; i<seek; i++ )
|
for ( i=1; i<seek; i++ )
|
||||||
if ( now_playing[i] == '\\' )
|
if ( buf[i] == '\\' )
|
||||||
now_playing[i] = '/';
|
buf[i] = '/';
|
||||||
|
|
||||||
if('/' == now_playing[1])
|
if('/' == buf[0]) {
|
||||||
return &now_playing[1];
|
strcpy(now_playing, &buf[0]);
|
||||||
|
return now_playing;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* handle dos style drive letter */
|
/* handle dos style drive letter */
|
||||||
if ( ':' == now_playing[2] )
|
if ( ':' == buf[1] ) {
|
||||||
return &now_playing[3];
|
strcpy(now_playing, &buf[2]);
|
||||||
|
return now_playing;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
now_playing[0]='/';
|
snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf);
|
||||||
return now_playing;
|
return now_playing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +121,7 @@ void play_list(char *dir, char *file)
|
||||||
lcd_puts(0,0,"Playing... ");
|
lcd_puts(0,0,"Playing... ");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
/* also make the first song get playing */
|
/* also make the first song get playing */
|
||||||
mpeg_play(playlist_next(0));
|
mpeg_play(playlist_next(0, dir));
|
||||||
sleep(HZ);
|
sleep(HZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +177,7 @@ void add_indices_to_playlist( playlist_info_t *playlist )
|
||||||
}
|
}
|
||||||
else if(store_index)
|
else if(store_index)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Store a new entry */
|
/* Store a new entry */
|
||||||
playlist->indices[ playlist->amount ] = i+count;
|
playlist->indices[ playlist->amount ] = i+count;
|
||||||
playlist->amount++;
|
playlist->amount++;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ extern playlist_info_t playlist;
|
||||||
extern bool playlist_shuffle;
|
extern bool playlist_shuffle;
|
||||||
|
|
||||||
void play_list(char *dir, char *file);
|
void play_list(char *dir, char *file);
|
||||||
char* playlist_next(int steps);
|
char* playlist_next(int steps, char *dirname);
|
||||||
void randomise_playlist( playlist_info_t *playlist, unsigned int seed );
|
void randomise_playlist( playlist_info_t *playlist, unsigned int seed );
|
||||||
void empty_playlist( playlist_info_t *playlist );
|
void empty_playlist( playlist_info_t *playlist );
|
||||||
void add_indices_to_playlist( playlist_info_t *playlist );
|
void add_indices_to_playlist( playlist_info_t *playlist );
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ char* peek_next_track(int steps)
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
/* playlist mode */
|
/* playlist mode */
|
||||||
return playlist_next(steps);
|
return playlist_next(steps, currdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue