diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2008-04-14 16:17:47 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2008-04-14 16:17:47 +0000 |
commit | 4e2de44b444e15a84c2e3ce1c30b2bcb074c5c6a (patch) | |
tree | c93b3fa9d0e3210cae0658ecd1d44673c62bd97c /apps/buffering.c | |
parent | a5ad74ffcaf8fc4d29fbc4457239d822c0215cde (diff) |
A rather big change to how tracks are loaded: there are now two parts to the process and metadata loading is done by the buffering thread (except for the first unbuffered track). The audio thread now calls audio_load_track, and once the metadata is loaded, the buffering thread sends an event which will make the audio thread call audio_finish_load_track. This one then takes care of the rest of the loading.
This method makes skipping noticeably faster for unbuffered tracks, and especially backwards.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17109 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index f123d8fcc3..113650fe9f 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -50,6 +50,7 @@ #include "buffer.h" #include "bmp.h" #include "events.h" +#include "metadata.h" #ifdef SIMULATOR #define ata_disk_is_active() 1 @@ -586,6 +587,18 @@ static bool buffer_handle(int handle_id) trigger_cpu_boost(); + if (h->type == TYPE_ID3) + { + get_metadata((struct mp3entry *)(buffer + h->data), h->fd, h->path); + close(h->fd); + h->fd = -1; + h->filerem = 0; + h->available = sizeof(struct mp3entry); + h->widx += sizeof(struct mp3entry); + send_event(EVENT_HANDLE_FINISHED, &h->id); + return true; + } + while (h->filerem > 0) { /* max amount to copy */ @@ -869,7 +882,31 @@ management functions for all the actual handle management work. */ int bufopen(const char *file, size_t offset, enum data_type type) { - size_t adjusted_offset = offset; + if (type == TYPE_ID3) + { + /* ID3 case: allocate space, init the handle and return. */ + + struct memory_handle *h = add_handle(sizeof(struct mp3entry), false, true); + if (!h) + return ERR_BUFFER_FULL; + + h->fd = -1; + h->filesize = sizeof(struct mp3entry); + h->filerem = sizeof(struct mp3entry); + h->offset = 0; + h->data = buf_widx; + h->ridx = buf_widx; + h->widx = buf_widx; + h->available = 0; + h->type = type; + strncpy(h->path, file, MAX_PATH); + + buf_widx += sizeof(struct mp3entry); /* safe because the handle + can't wrap */ + return h->id; + } + + /* Other cases: there is a little more work. */ int fd = open(file, O_RDONLY); if (fd < 0) @@ -878,6 +915,7 @@ int bufopen(const char *file, size_t offset, enum data_type type) size_t size = filesize(fd); bool can_wrap = type==TYPE_PACKET_AUDIO || type==TYPE_CODEC; + size_t adjusted_offset = offset; if (adjusted_offset > size) adjusted_offset = 0; |