forked from len0rd/rockbox
efficiency improvement
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2265 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0be1d26674
commit
e9d5127eaa
1 changed files with 31 additions and 36 deletions
|
|
@ -301,9 +301,9 @@ void add_indices_to_playlist(void)
|
||||||
int nread;
|
int nread;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int store_index = 0;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int next_tick = current_tick + HZ;
|
int next_tick = current_tick + HZ;
|
||||||
|
bool store_index = true;
|
||||||
|
|
||||||
unsigned char *p = playlist_buffer;
|
unsigned char *p = playlist_buffer;
|
||||||
char line[16];
|
char line[16];
|
||||||
|
|
@ -314,7 +314,7 @@ void add_indices_to_playlist(void)
|
||||||
return; /* failure */
|
return; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
store_index = 1;
|
store_index = true;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
@ -334,47 +334,42 @@ void add_indices_to_playlist(void)
|
||||||
/* Are we on a new line? */
|
/* Are we on a new line? */
|
||||||
if((*p == '\n') || (*p == '\r'))
|
if((*p == '\n') || (*p == '\r'))
|
||||||
{
|
{
|
||||||
store_index = 1;
|
store_index = true;
|
||||||
}
|
}
|
||||||
else if(!playlist.in_ram && (*p == '#') && store_index)
|
|
||||||
{
|
|
||||||
/* If the first character on a new line is a hash
|
|
||||||
sign, we treat it as a comment. So called winamp
|
|
||||||
style playlist.
|
|
||||||
This applies only to playlist files, of course */
|
|
||||||
store_index = 0;
|
|
||||||
}
|
|
||||||
else if(store_index)
|
else if(store_index)
|
||||||
{
|
{
|
||||||
|
store_index = false;
|
||||||
/* Store a new entry */
|
|
||||||
playlist.indices[ playlist.amount ] = i+count;
|
|
||||||
playlist.amount++;
|
|
||||||
if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
|
|
||||||
if(!playlist.in_ram)
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
lcd_clear_display();
|
if(playlist.in_ram || (*p != '#'))
|
||||||
lcd_puts(0,0,"Playlist");
|
{
|
||||||
lcd_puts(0,1,"buffer full");
|
/* Store a new entry */
|
||||||
lcd_update();
|
playlist.indices[ playlist.amount ] = i+count;
|
||||||
sleep(HZ*2);
|
playlist.amount++;
|
||||||
lcd_clear_display();
|
if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
|
||||||
|
if(!playlist.in_ram)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
return;
|
lcd_clear_display();
|
||||||
}
|
lcd_puts(0,0,"Playlist");
|
||||||
|
lcd_puts(0,1,"buffer full");
|
||||||
store_index = 0;
|
|
||||||
/* Update the screen if it takes very long */
|
|
||||||
if(!playlist.in_ram) {
|
|
||||||
if ( current_tick >= next_tick ) {
|
|
||||||
next_tick = current_tick + HZ;
|
|
||||||
snprintf(line, sizeof line, "%d files",
|
|
||||||
playlist.amount);
|
|
||||||
lcd_puts(0,1,line);
|
|
||||||
status_draw();
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
sleep(HZ*2);
|
||||||
|
lcd_clear_display();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the screen if it takes very long */
|
||||||
|
if(!playlist.in_ram) {
|
||||||
|
if ( current_tick >= next_tick ) {
|
||||||
|
next_tick = current_tick + HZ;
|
||||||
|
snprintf(line, sizeof line, "%d files",
|
||||||
|
playlist.amount);
|
||||||
|
lcd_puts(0,1,line);
|
||||||
|
status_draw();
|
||||||
|
lcd_update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue