diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-12-17 16:12:10 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-12-17 16:33:50 -0500 |
commit | dfff938dff089667038041fcb66262c87c3186c2 (patch) | |
tree | f592218ad9b33d8b0bb0e5c07bcb155f6243aaf4 /apps/buffering.c | |
parent | d14e3f45a859045e81065bfd6740605be45c2349 (diff) | |
download | rockbox-dfff938dff089667038041fcb66262c87c3186c2.tar.gz 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.c | 42 |
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 { | |||
93 | size_t data; /* Start index of the handle's data buffer */ | 93 | size_t data; /* Start index of the handle's data buffer */ |
94 | size_t ridx; /* Read pointer, relative to the main buffer */ | 94 | size_t ridx; /* Read pointer, relative to the main buffer */ |
95 | size_t widx; /* Write pointer, relative to the main buffer */ | 95 | size_t widx; /* Write pointer, relative to the main buffer */ |
96 | ssize_t filesize; /* File total length */ | 96 | off_t filesize; /* File total length (possibly trimmed at tail) */ |
97 | off_t start; /* Offset at which we started reading the file */ | 97 | off_t start; /* Offset at which we started reading the file */ |
98 | off_t pos; /* Read position in file */ | 98 | off_t pos; /* Read position in file */ |
99 | off_t volatile end; /* Offset at which we stopped reading the file */ | 99 | 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. | |||
917 | return value: <0 if the file cannot be opened, or one file already | 917 | return value: <0 if the file cannot be opened, or one file already |
918 | queued to be opened, otherwise the handle for the file in the buffer | 918 | queued to be opened, otherwise the handle for the file in the buffer |
919 | */ | 919 | */ |
920 | int bufopen(const char *file, size_t offset, enum data_type type, | 920 | int bufopen(const char *file, off_t offset, enum data_type type, |
921 | void *user_data) | 921 | void *user_data) |
922 | { | 922 | { |
923 | int handle_id = ERR_BUFFER_FULL; | 923 | int handle_id = ERR_BUFFER_FULL; |
@@ -1508,31 +1508,36 @@ These functions are exported, to allow interaction with the buffer. | |||
1508 | They take care of the content of the structs, and rely on the linked list | 1508 | They take care of the content of the structs, and rely on the linked list |
1509 | management functions for all the actual handle management work. | 1509 | management functions for all the actual handle management work. |
1510 | */ | 1510 | */ |
1511 | bool buf_is_handle(int handle_id) | ||
1512 | { | ||
1513 | return find_handle(handle_id) != NULL; | ||
1514 | } | ||
1511 | 1515 | ||
1512 | ssize_t buf_handle_offset(int handle_id) | 1516 | int buf_handle_data_type(int handle_id) |
1513 | { | 1517 | { |
1514 | const struct memory_handle *h = find_handle(handle_id); | 1518 | const struct memory_handle *h = find_handle(handle_id); |
1515 | if (!h) | 1519 | if (!h) |
1516 | return ERR_HANDLE_NOT_FOUND; | 1520 | return ERR_HANDLE_NOT_FOUND; |
1517 | return h->start; | 1521 | return h->type; |
1518 | } | 1522 | } |
1519 | 1523 | ||
1520 | void buf_set_base_handle(int handle_id) | 1524 | off_t buf_filesize(int handle_id) |
1521 | { | 1525 | { |
1522 | mutex_lock(&llist_mutex); | 1526 | const struct memory_handle *h = find_handle(handle_id); |
1523 | base_handle_id = handle_id; | 1527 | if (!h) |
1524 | mutex_unlock(&llist_mutex); | 1528 | return ERR_HANDLE_NOT_FOUND; |
1529 | return h->filesize; | ||
1525 | } | 1530 | } |
1526 | 1531 | ||
1527 | enum data_type buf_handle_data_type(int handle_id) | 1532 | off_t buf_handle_offset(int handle_id) |
1528 | { | 1533 | { |
1529 | const struct memory_handle *h = find_handle(handle_id); | 1534 | const struct memory_handle *h = find_handle(handle_id); |
1530 | if (!h) | 1535 | if (!h) |
1531 | return TYPE_UNKNOWN; | 1536 | return ERR_HANDLE_NOT_FOUND; |
1532 | return h->type; | 1537 | return h->start; |
1533 | } | 1538 | } |
1534 | 1539 | ||
1535 | ssize_t buf_handle_remaining(int handle_id) | 1540 | off_t buf_handle_remaining(int handle_id) |
1536 | { | 1541 | { |
1537 | const struct memory_handle *h = find_handle(handle_id); | 1542 | const struct memory_handle *h = find_handle(handle_id); |
1538 | if (!h) | 1543 | if (!h) |
@@ -1540,11 +1545,6 @@ ssize_t buf_handle_remaining(int handle_id) | |||
1540 | return h->filesize - h->end; | 1545 | return h->filesize - h->end; |
1541 | } | 1546 | } |
1542 | 1547 | ||
1543 | bool buf_is_handle(int handle_id) | ||
1544 | { | ||
1545 | return find_handle(handle_id) != NULL; | ||
1546 | } | ||
1547 | |||
1548 | bool buf_pin_handle(int handle_id, bool pin) | 1548 | bool buf_pin_handle(int handle_id, bool pin) |
1549 | { | 1549 | { |
1550 | struct memory_handle *h = find_handle(handle_id); | 1550 | struct memory_handle *h = find_handle(handle_id); |
@@ -1576,6 +1576,14 @@ size_t buf_length(void) | |||
1576 | return buffer_len; | 1576 | return buffer_len; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | /* Set the handle from which useful data is counted */ | ||
1580 | void buf_set_base_handle(int handle_id) | ||
1581 | { | ||
1582 | mutex_lock(&llist_mutex); | ||
1583 | base_handle_id = handle_id; | ||
1584 | mutex_unlock(&llist_mutex); | ||
1585 | } | ||
1586 | |||
1579 | /* Return the amount of buffer space used */ | 1587 | /* Return the amount of buffer space used */ |
1580 | size_t buf_used(void) | 1588 | size_t buf_used(void) |
1581 | { | 1589 | { |