summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-04-23 18:45:51 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-04-23 18:45:51 +0000
commit583821bc323f4a49abd9f295a6eea01bb0f4473b (patch)
tree439546a79d2f1d4c249315d67abe658762cff70f /apps
parent6cafc14e75e09922cc8723773da3a7daa59fa89c (diff)
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
Diffstat (limited to 'apps')
-rw-r--r--apps/playlist.c33
-rw-r--r--apps/playlist.h1
2 files changed, 17 insertions, 17 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index ebe82cc457..4a06606509 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -58,6 +58,10 @@ static void empty_playlist(bool queue_resume)
int fd;
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.queue_index = 0;
playlist.last_queue_index = 0;
@@ -390,8 +394,8 @@ char* playlist_peek(int steps)
{
int seek;
int max;
- int fd;
int i;
+ int fd;
char *buf;
char dir_buf[MAX_PATH+1];
char *dir_end;
@@ -427,13 +431,14 @@ char* playlist_peek(int steps)
}
else
{
- fd = open(playlist.filename, O_RDONLY);
- if(-1 != fd)
+ if(-1 == playlist.fd)
+ playlist.fd = open(playlist.filename, O_RDONLY);
+
+ if(-1 != playlist.fd)
{
buf = playlist_buffer;
- lseek(fd, seek, SEEK_SET);
- max = read(fd, buf, MAX_PATH);
- close(fd);
+ lseek(playlist.fd, seek, SEEK_SET);
+ max = read(playlist.fd, buf, MAX_PATH);
}
else
return NULL;
@@ -642,7 +647,6 @@ int play_list(char *dir, /* "current directory" */
void add_indices_to_playlist(void)
{
int nread;
- int fd = -1;
int i = 0;
int count = 0;
unsigned char* buffer = playlist_buffer;
@@ -651,10 +655,11 @@ void add_indices_to_playlist(void)
unsigned char *p;
if(!playlist.in_ram) {
- fd = open(playlist.filename, O_RDONLY);
- if(-1 == fd)
+ if(-1 == playlist.fd)
+ playlist.fd = open(playlist.filename, O_RDONLY);
+ if(-1 == playlist.fd)
return; /* failure */
-
+
#ifndef SIMULATOR
/* use mp3 buffer for maximum load speed */
buflen = (&mp3end - &mp3buf[0]);
@@ -671,7 +676,7 @@ void add_indices_to_playlist(void)
if(playlist.in_ram) {
nread = playlist_end_pos;
} else {
- nread = read(fd, buffer, buflen);
+ nread = read(playlist.fd, buffer, buflen);
/* Terminate on EOF */
if(nread <= 0)
break;
@@ -696,9 +701,6 @@ void add_indices_to_playlist(void)
playlist.indices[ playlist.amount ] = i+count;
playlist.amount++;
if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
- if(!playlist.in_ram)
- close(fd);
-
lcd_clear_display();
lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST));
lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER));
@@ -717,9 +719,6 @@ void add_indices_to_playlist(void)
if(playlist.in_ram)
break;
}
-
- if(!playlist.in_ram)
- close(fd);
}
/*
diff --git a/apps/playlist.h b/apps/playlist.h
index ea77886bb7..9f70b469af 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -29,6 +29,7 @@
struct playlist_info
{
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 indices[MAX_PLAYLIST_SIZE]; /* array of indices */
int index; /* index of current playing track */