summaryrefslogtreecommitdiffstats
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-05-09 21:19:11 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-05-09 21:19:11 +0000
commit5a8f5b833093961096c7787ed46a18b4d69b554c (patch)
tree2517f7513c407454498fc5d9b000544312dd3fc3 /apps/buffering.c
parent12e8e432368a300517a789bd6045502964ad95cf (diff)
downloadrockbox-5a8f5b833093961096c7787ed46a18b4d69b554c.tar.gz
rockbox-5a8f5b833093961096c7787ed46a18b4d69b554c.tar.bz2
rockbox-5a8f5b833093961096c7787ed46a18b4d69b554c.zip
Provide a reasonable fix for FS#12093 - Playback hanging after codec/playback rework. Also, get rid of an impossible buffering case (BUF_USED is always less than buffer_len) and remove a buffering API that is not used anywhere and shouldn't be needed (plugin API has to be incompatible).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29849 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index a130a787ff..c47564b7e1 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1339,7 +1339,8 @@ static struct memory_handle *prep_bufdata(int handle_id, size_t *size,
if (h->filerem > 0 && avail < realsize) {
/* Data isn't ready. Request buffering */
- buf_request_buffer_handle(handle_id);
+ LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id);
+ queue_send(&buffering_queue, Q_START_FILL, handle_id);
/* Wait for the data to be ready */
do
{
@@ -1486,7 +1487,6 @@ SECONDARY EXPORTED FUNCTIONS
============================
buf_handle_offset
-buf_request_buffer_handle
buf_set_base_handle
buf_handle_data_type
buf_is_handle
@@ -1510,12 +1510,6 @@ ssize_t buf_handle_offset(int handle_id)
return h->offset;
}
-void buf_request_buffer_handle(int handle_id)
-{
- LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id);
- queue_send(&buffering_queue, Q_START_FILL, handle_id);
-}
-
void buf_set_base_handle(int handle_id)
{
mutex_lock(&llist_mutex);
@@ -1642,7 +1636,15 @@ static void NORETURN_ATTR buffering_thread(void)
LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data);
shrink_buffer();
queue_reply(&buffering_queue, 1);
- filling |= buffer_handle((int)ev.data, 0);
+ if (buffer_handle((int)ev.data, 0)) {
+ filling = true;
+ }
+ else if (num_handles > 0 && conf_watermark > 0) {
+ update_data_counters(NULL);
+ if (data_counters.useful >= BUF_WATERMARK) {
+ send_event(BUFFER_EVENT_BUFFER_LOW, NULL);
+ }
+ }
break;
case Q_BUFFER_HANDLE:
@@ -1699,12 +1701,7 @@ static void NORETURN_ATTR buffering_thread(void)
#endif
if (filling) {
- if (data_counters.remaining > 0 && BUF_USED < buffer_len) {
- filling = fill_buffer();
- }
- else if (data_counters.remaining == 0) {
- filling = false;
- }
+ filling = data_counters.remaining > 0 ? fill_buffer() : false;
} else if (ev.id == SYS_TIMEOUT) {
if (data_counters.useful < BUF_WATERMARK) {
/* The buffer is low and we're idle, just watching the levels