diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 65ab494d18..12749dba67 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -58,8 +58,8 @@ char* playlist_next(int type) | |||
58 | (now_playing[seek] != '\r') && | 58 | (now_playing[seek] != '\r') && |
59 | (seek < max)) | 59 | (seek < max)) |
60 | seek++; | 60 | seek++; |
61 | if(seek == max) | 61 | /* if(seek == max) |
62 | seek = max-1; | 62 | seek = max-1;*/ |
63 | now_playing[seek]=0; | 63 | now_playing[seek]=0; |
64 | 64 | ||
65 | return now_playing; | 65 | return now_playing; |
@@ -100,22 +100,31 @@ void empty_playlist( playlist_info_t *playlist ) | |||
100 | */ | 100 | */ |
101 | void add_indices_to_playlist( playlist_info_t *playlist ) | 101 | void add_indices_to_playlist( playlist_info_t *playlist ) |
102 | { | 102 | { |
103 | /* | ||
103 | char *p; | 104 | char *p; |
104 | int i = 0; | 105 | int i = 0; |
105 | unsigned char byte; | 106 | unsigned char byte; |
106 | unsigned char lastbyte='\n'; | 107 | unsigned char lastbyte='\n'; |
108 | */ | ||
107 | int nread; | 109 | int nread; |
108 | 110 | ||
109 | int fd; | 111 | int fd; |
110 | 112 | ||
113 | int i = 0; | ||
114 | unsigned char *p; | ||
115 | unsigned char buf[255]; | ||
116 | int store_index = 0; | ||
117 | int count = 0; | ||
118 | |||
111 | fd = open(playlist->filename, O_RDONLY); | 119 | fd = open(playlist->filename, O_RDONLY); |
112 | if(-1 == fd) | 120 | if(-1 == fd) |
113 | return; /* failure */ | 121 | return; /* failure */ |
114 | 122 | ||
115 | p = &byte; | 123 | #ifdef ROBHAK |
124 | p = &byte; /* Not being used? */ | ||
116 | 125 | ||
117 | /* loop thru buffer, store index whenever we get a new line */ | 126 | /* loop thru buffer, store index whenever we get a new line */ |
118 | 127 | ||
119 | while((nread = read(fd, &byte, 1)) == 1) | 128 | while((nread = read(fd, &byte, 1)) == 1) |
120 | { | 129 | { |
121 | /* move thru (any) newlines */ | 130 | /* move thru (any) newlines */ |
@@ -131,6 +140,34 @@ void add_indices_to_playlist( playlist_info_t *playlist ) | |||
131 | i++; | 140 | i++; |
132 | lastbyte = byte; | 141 | lastbyte = byte; |
133 | } | 142 | } |
143 | #endif | ||
144 | store_index = 1; | ||
145 | |||
146 | while((nread = read(fd, &buf, sizeof(buf))) != 0) | ||
147 | { | ||
148 | p = buf; | ||
149 | |||
150 | for(count=0; count < nread; count++,p++) { | ||
151 | |||
152 | /* Are we on a new line? */ | ||
153 | if(((*p == '\n') || (*p == '\r')) && (!store_index)) | ||
154 | { | ||
155 | store_index = 1; | ||
156 | } | ||
157 | else if(store_index) | ||
158 | { | ||
159 | /* Store a new entry */ | ||
160 | DEBUGF("tune %d at position %d\n", playlist->amount, i+count); | ||
161 | playlist->indices[ playlist->amount ] = i+count; | ||
162 | playlist->amount++; | ||
163 | |||
164 | store_index = 0; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | i+= count; | ||
169 | } | ||
170 | |||
134 | 171 | ||
135 | close(fd); | 172 | close(fd); |
136 | } | 173 | } |