summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-07-05 12:48:17 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-07-05 12:48:17 +0000
commit6b91b7ea57ee2798c2b86853e4e4aa95bbb3ddaa (patch)
treedb32c2e733feab1dff292b34a223c406b587e8f5 /apps/playlist.c
parent75447f6d413286e2925f7b44cb53753f34590c02 (diff)
downloadrockbox-6b91b7ea57ee2798c2b86853e4e4aa95bbb3ddaa.tar.gz
rockbox-6b91b7ea57ee2798c2b86853e4e4aa95bbb3ddaa.zip
Relative path playlist patch by Mat Pritchard
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1342 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 4a2a6fdab2..2d8bbd3a33 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -33,14 +33,15 @@
33 33
34playlist_info_t playlist; 34playlist_info_t playlist;
35 35
36char now_playing[256]; 36char now_playing[MAX_PATH+1];
37 37
38char* playlist_next(int steps) 38char* playlist_next(int steps, char *dirname)
39{ 39{
40 int seek; 40 int seek;
41 int max; 41 int max;
42 int fd; 42 int fd;
43 int i; 43 int i;
44 char buf[MAX_PATH+1];
44 45
45 playlist.index = (playlist.index+steps) % playlist.amount; 46 playlist.index = (playlist.index+steps) % playlist.amount;
46 seek = playlist.indices[playlist.index]; 47 seek = playlist.indices[playlist.index];
@@ -48,36 +49,40 @@ char* playlist_next(int steps)
48 fd = open(playlist.filename, O_RDONLY); 49 fd = open(playlist.filename, O_RDONLY);
49 if(-1 != fd) { 50 if(-1 != fd) {
50 lseek(fd, seek, SEEK_SET); 51 lseek(fd, seek, SEEK_SET);
51 max = read(fd, now_playing+1, sizeof(now_playing)-1); 52 max = read(fd, buf, sizeof(buf)-1);
52 close(fd); 53 close(fd);
53 54
54 /* Zero-terminate the file name */ 55 /* Zero-terminate the file name */
55 seek=0; 56 seek=0;
56 while((now_playing[seek] != '\n') && 57 while((buf[seek] != '\n') &&
57 (now_playing[seek] != '\r') && 58 (buf[seek] != '\r') &&
58 (seek < max)) 59 (seek < max))
59 seek++; 60 seek++;
60 61
61 /* Now work back killing white space */ 62 /* Now work back killing white space */
62 while((now_playing[seek-1] == ' ') || 63 while((buf[seek-1] == ' ') ||
63 (now_playing[seek-1] == '\t')) 64 (buf[seek-1] == '\t'))
64 seek--; 65 seek--;
65 66
66 now_playing[seek]=0; 67 buf[seek]=0;
67 68
68 /* replace backslashes with forward slashes */ 69 /* replace backslashes with forward slashes */
69 for ( i=1; i<seek; i++ ) 70 for ( i=1; i<seek; i++ )
70 if ( now_playing[i] == '\\' ) 71 if ( buf[i] == '\\' )
71 now_playing[i] = '/'; 72 buf[i] = '/';
72 73
73 if('/' == now_playing[1]) 74 if('/' == buf[0]) {
74 return &now_playing[1]; 75 strcpy(now_playing, &buf[0]);
76 return now_playing;
77 }
75 else { 78 else {
76 /* handle dos style drive letter */ 79 /* handle dos style drive letter */
77 if ( ':' == now_playing[2] ) 80 if ( ':' == buf[1] ) {
78 return &now_playing[3]; 81 strcpy(now_playing, &buf[2]);
82 return now_playing;
83 }
79 else { 84 else {
80 now_playing[0]='/'; 85 snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf);
81 return now_playing; 86 return now_playing;
82 } 87 }
83 } 88 }
@@ -116,7 +121,7 @@ void play_list(char *dir, char *file)
116 lcd_puts(0,0,"Playing... "); 121 lcd_puts(0,0,"Playing... ");
117 lcd_update(); 122 lcd_update();
118 /* also make the first song get playing */ 123 /* also make the first song get playing */
119 mpeg_play(playlist_next(0)); 124 mpeg_play(playlist_next(0, dir));
120 sleep(HZ); 125 sleep(HZ);
121} 126}
122 127
@@ -172,7 +177,7 @@ void add_indices_to_playlist( playlist_info_t *playlist )
172 } 177 }
173 else if(store_index) 178 else if(store_index)
174 { 179 {
175 180
176 /* Store a new entry */ 181 /* Store a new entry */
177 playlist->indices[ playlist->amount ] = i+count; 182 playlist->indices[ playlist->amount ] = i+count;
178 playlist->amount++; 183 playlist->amount++;