mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-19 01:52:35 -05:00
Keep the playlist open all the time, to reduce mid-song times caused by the
closure and reopening of the playlist. Consider this slightly experimental. Can you detect a speed difference? git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3592 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6cafc14e75
commit
583821bc32
2 changed files with 17 additions and 17 deletions
|
|
@ -58,6 +58,10 @@ static void empty_playlist(bool queue_resume)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
playlist.filename[0] = '\0';
|
playlist.filename[0] = '\0';
|
||||||
|
if(-1 != playlist.fd)
|
||||||
|
/* If there is an already open playlist, close it. */
|
||||||
|
close(playlist.fd);
|
||||||
|
playlist.fd = -1;
|
||||||
playlist.index = 0;
|
playlist.index = 0;
|
||||||
playlist.queue_index = 0;
|
playlist.queue_index = 0;
|
||||||
playlist.last_queue_index = 0;
|
playlist.last_queue_index = 0;
|
||||||
|
|
@ -390,8 +394,8 @@ char* playlist_peek(int steps)
|
||||||
{
|
{
|
||||||
int seek;
|
int seek;
|
||||||
int max;
|
int max;
|
||||||
int fd;
|
|
||||||
int i;
|
int i;
|
||||||
|
int fd;
|
||||||
char *buf;
|
char *buf;
|
||||||
char dir_buf[MAX_PATH+1];
|
char dir_buf[MAX_PATH+1];
|
||||||
char *dir_end;
|
char *dir_end;
|
||||||
|
|
@ -427,13 +431,14 @@ char* playlist_peek(int steps)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fd = open(playlist.filename, O_RDONLY);
|
if(-1 == playlist.fd)
|
||||||
if(-1 != fd)
|
playlist.fd = open(playlist.filename, O_RDONLY);
|
||||||
|
|
||||||
|
if(-1 != playlist.fd)
|
||||||
{
|
{
|
||||||
buf = playlist_buffer;
|
buf = playlist_buffer;
|
||||||
lseek(fd, seek, SEEK_SET);
|
lseek(playlist.fd, seek, SEEK_SET);
|
||||||
max = read(fd, buf, MAX_PATH);
|
max = read(playlist.fd, buf, MAX_PATH);
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -642,7 +647,6 @@ int play_list(char *dir, /* "current directory" */
|
||||||
void add_indices_to_playlist(void)
|
void add_indices_to_playlist(void)
|
||||||
{
|
{
|
||||||
int nread;
|
int nread;
|
||||||
int fd = -1;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
unsigned char* buffer = playlist_buffer;
|
unsigned char* buffer = playlist_buffer;
|
||||||
|
|
@ -651,8 +655,9 @@ void add_indices_to_playlist(void)
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
|
|
||||||
if(!playlist.in_ram) {
|
if(!playlist.in_ram) {
|
||||||
fd = open(playlist.filename, O_RDONLY);
|
if(-1 == playlist.fd)
|
||||||
if(-1 == fd)
|
playlist.fd = open(playlist.filename, O_RDONLY);
|
||||||
|
if(-1 == playlist.fd)
|
||||||
return; /* failure */
|
return; /* failure */
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
@ -671,7 +676,7 @@ void add_indices_to_playlist(void)
|
||||||
if(playlist.in_ram) {
|
if(playlist.in_ram) {
|
||||||
nread = playlist_end_pos;
|
nread = playlist_end_pos;
|
||||||
} else {
|
} else {
|
||||||
nread = read(fd, buffer, buflen);
|
nread = read(playlist.fd, buffer, buflen);
|
||||||
/* Terminate on EOF */
|
/* Terminate on EOF */
|
||||||
if(nread <= 0)
|
if(nread <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
@ -696,9 +701,6 @@ void add_indices_to_playlist(void)
|
||||||
playlist.indices[ playlist.amount ] = i+count;
|
playlist.indices[ playlist.amount ] = i+count;
|
||||||
playlist.amount++;
|
playlist.amount++;
|
||||||
if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
|
if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
|
||||||
if(!playlist.in_ram)
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST));
|
lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST));
|
||||||
lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER));
|
lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER));
|
||||||
|
|
@ -717,9 +719,6 @@ void add_indices_to_playlist(void)
|
||||||
if(playlist.in_ram)
|
if(playlist.in_ram)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!playlist.in_ram)
|
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
struct playlist_info
|
struct playlist_info
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH]; /* path name of m3u playlist on disk */
|
char filename[MAX_PATH]; /* path name of m3u playlist on disk */
|
||||||
|
int fd; /* file descriptor of the open playlist */
|
||||||
int dirlen; /* Length of the path to the playlist file */
|
int dirlen; /* Length of the path to the playlist file */
|
||||||
int indices[MAX_PLAYLIST_SIZE]; /* array of indices */
|
int indices[MAX_PLAYLIST_SIZE]; /* array of indices */
|
||||||
int index; /* index of current playing track */
|
int index; /* index of current playing track */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue