1
0
Fork 0
forked from len0rd/rockbox

we now handle playlists in a block of 255 bytes instead of a single byte at a time

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@946 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Hak 2002-06-11 07:30:31 +00:00
parent ded0946096
commit 06b4e7f8bc

View file

@ -58,8 +58,8 @@ char* playlist_next(int type)
(now_playing[seek] != '\r') &&
(seek < max))
seek++;
if(seek == max)
seek = max-1;
/* if(seek == max)
seek = max-1;*/
now_playing[seek]=0;
return now_playing;
@ -100,19 +100,28 @@ void empty_playlist( playlist_info_t *playlist )
*/
void add_indices_to_playlist( playlist_info_t *playlist )
{
/*
char *p;
int i = 0;
unsigned char byte;
unsigned char lastbyte='\n';
*/
int nread;
int fd;
int i = 0;
unsigned char *p;
unsigned char buf[255];
int store_index = 0;
int count = 0;
fd = open(playlist->filename, O_RDONLY);
if(-1 == fd)
return; /* failure */
p = &byte;
#ifdef ROBHAK
p = &byte; /* Not being used? */
/* loop thru buffer, store index whenever we get a new line */
@ -131,6 +140,34 @@ void add_indices_to_playlist( playlist_info_t *playlist )
i++;
lastbyte = byte;
}
#endif
store_index = 1;
while((nread = read(fd, &buf, sizeof(buf))) != 0)
{
p = buf;
for(count=0; count < nread; count++,p++) {
/* Are we on a new line? */
if(((*p == '\n') || (*p == '\r')) && (!store_index))
{
store_index = 1;
}
else if(store_index)
{
/* Store a new entry */
DEBUGF("tune %d at position %d\n", playlist->amount, i+count);
playlist->indices[ playlist->amount ] = i+count;
playlist->amount++;
store_index = 0;
}
}
i+= count;
}
close(fd);
}