summaryrefslogtreecommitdiffstats
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-12-17 16:12:10 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-12-17 16:33:50 -0500
commitdfff938dff089667038041fcb66262c87c3186c2 (patch)
treef592218ad9b33d8b0bb0e5c07bcb155f6243aaf4 /apps/buffering.c
parentd14e3f45a859045e81065bfd6740605be45c2349 (diff)
downloadrockbox-dfff938dff089667038041fcb66262c87c3186c2.tar.gz
rockbox-dfff938dff089667038041fcb66262c87c3186c2.tar.bz2
rockbox-dfff938dff089667038041fcb66262c87c3186c2.zip
Get rid of useless playlist probing and fix up some data types.
Playback checked the files' presence before attempting to buffer the track. Just get rid of that and save an extra open/close call. It will find out if the path is bad when the metadata fails. Fix some size_t/off_t conflation. No need to update plugin version because no plugin actually uses bufopen(). Change-Id: I3db112449dc0b2eeb91c546f308880ac82494fc7
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 72b3890ef0..027d33a486 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -93,7 +93,7 @@ struct memory_handle {
size_t data; /* Start index of the handle's data buffer */
size_t ridx; /* Read pointer, relative to the main buffer */
size_t widx; /* Write pointer, relative to the main buffer */
- ssize_t filesize; /* File total length */
+ off_t filesize; /* File total length (possibly trimmed at tail) */
off_t start; /* Offset at which we started reading the file */
off_t pos; /* Read position in file */
off_t volatile end; /* Offset at which we stopped reading the file */
@@ -917,7 +917,7 @@ management functions for all the actual handle management work.
return value: <0 if the file cannot be opened, or one file already
queued to be opened, otherwise the handle for the file in the buffer
*/
-int bufopen(const char *file, size_t offset, enum data_type type,
+int bufopen(const char *file, off_t offset, enum data_type type,
void *user_data)
{
int handle_id = ERR_BUFFER_FULL;
@@ -1508,31 +1508,36 @@ These functions are exported, to allow interaction with the buffer.
They take care of the content of the structs, and rely on the linked list
management functions for all the actual handle management work.
*/
+bool buf_is_handle(int handle_id)
+{
+ return find_handle(handle_id) != NULL;
+}
-ssize_t buf_handle_offset(int handle_id)
+int buf_handle_data_type(int handle_id)
{
const struct memory_handle *h = find_handle(handle_id);
if (!h)
return ERR_HANDLE_NOT_FOUND;
- return h->start;
+ return h->type;
}
-void buf_set_base_handle(int handle_id)
+off_t buf_filesize(int handle_id)
{
- mutex_lock(&llist_mutex);
- base_handle_id = handle_id;
- mutex_unlock(&llist_mutex);
+ const struct memory_handle *h = find_handle(handle_id);
+ if (!h)
+ return ERR_HANDLE_NOT_FOUND;
+ return h->filesize;
}
-enum data_type buf_handle_data_type(int handle_id)
+off_t buf_handle_offset(int handle_id)
{
const struct memory_handle *h = find_handle(handle_id);
if (!h)
- return TYPE_UNKNOWN;
- return h->type;
+ return ERR_HANDLE_NOT_FOUND;
+ return h->start;
}
-ssize_t buf_handle_remaining(int handle_id)
+off_t buf_handle_remaining(int handle_id)
{
const struct memory_handle *h = find_handle(handle_id);
if (!h)
@@ -1540,11 +1545,6 @@ ssize_t buf_handle_remaining(int handle_id)
return h->filesize - h->end;
}
-bool buf_is_handle(int handle_id)
-{
- return find_handle(handle_id) != NULL;
-}
-
bool buf_pin_handle(int handle_id, bool pin)
{
struct memory_handle *h = find_handle(handle_id);
@@ -1576,6 +1576,14 @@ size_t buf_length(void)
return buffer_len;
}
+/* Set the handle from which useful data is counted */
+void buf_set_base_handle(int handle_id)
+{
+ mutex_lock(&llist_mutex);
+ base_handle_id = handle_id;
+ mutex_unlock(&llist_mutex);
+}
+
/* Return the amount of buffer space used */
size_t buf_used(void)
{