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:
parent
ded0946096
commit
06b4e7f8bc
1 changed files with 42 additions and 5 deletions
|
@ -58,8 +58,8 @@ char* playlist_next(int type)
|
||||||
(now_playing[seek] != '\r') &&
|
(now_playing[seek] != '\r') &&
|
||||||
(seek < max))
|
(seek < max))
|
||||||
seek++;
|
seek++;
|
||||||
if(seek == max)
|
/* if(seek == max)
|
||||||
seek = max-1;
|
seek = max-1;*/
|
||||||
now_playing[seek]=0;
|
now_playing[seek]=0;
|
||||||
|
|
||||||
return now_playing;
|
return now_playing;
|
||||||
|
@ -100,22 +100,31 @@ 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 )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
char *p;
|
char *p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
unsigned char lastbyte='\n';
|
unsigned char lastbyte='\n';
|
||||||
|
*/
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
int fd;
|
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);
|
fd = open(playlist->filename, O_RDONLY);
|
||||||
if(-1 == fd)
|
if(-1 == fd)
|
||||||
return; /* failure */
|
return; /* failure */
|
||||||
|
|
||||||
p = &byte;
|
#ifdef ROBHAK
|
||||||
|
p = &byte; /* Not being used? */
|
||||||
|
|
||||||
/* loop thru buffer, store index whenever we get a new line */
|
/* loop thru buffer, store index whenever we get a new line */
|
||||||
|
|
||||||
while((nread = read(fd, &byte, 1)) == 1)
|
while((nread = read(fd, &byte, 1)) == 1)
|
||||||
{
|
{
|
||||||
/* move thru (any) newlines */
|
/* move thru (any) newlines */
|
||||||
|
@ -131,6 +140,34 @@ void add_indices_to_playlist( playlist_info_t *playlist )
|
||||||
i++;
|
i++;
|
||||||
lastbyte = byte;
|
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);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue