summaryrefslogtreecommitdiff
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
parent12e8e432368a300517a789bd6045502964ad95cf (diff)
downloadrockbox-5a8f5b833093961096c7787ed46a18b4d69b554c.tar.gz
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
-rw-r--r--apps/buffering.c27
-rw-r--r--apps/buffering.h2
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h5
4 files changed, 14 insertions, 21 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,
1339 1339
1340 if (h->filerem > 0 && avail < realsize) { 1340 if (h->filerem > 0 && avail < realsize) {
1341 /* Data isn't ready. Request buffering */ 1341 /* Data isn't ready. Request buffering */
1342 buf_request_buffer_handle(handle_id); 1342 LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id);
1343 queue_send(&buffering_queue, Q_START_FILL, handle_id);
1343 /* Wait for the data to be ready */ 1344 /* Wait for the data to be ready */
1344 do 1345 do
1345 { 1346 {
@@ -1486,7 +1487,6 @@ SECONDARY EXPORTED FUNCTIONS
1486============================ 1487============================
1487 1488
1488buf_handle_offset 1489buf_handle_offset
1489buf_request_buffer_handle
1490buf_set_base_handle 1490buf_set_base_handle
1491buf_handle_data_type 1491buf_handle_data_type
1492buf_is_handle 1492buf_is_handle
@@ -1510,12 +1510,6 @@ ssize_t buf_handle_offset(int handle_id)
1510 return h->offset; 1510 return h->offset;
1511} 1511}
1512 1512
1513void buf_request_buffer_handle(int handle_id)
1514{
1515 LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id);
1516 queue_send(&buffering_queue, Q_START_FILL, handle_id);
1517}
1518
1519void buf_set_base_handle(int handle_id) 1513void buf_set_base_handle(int handle_id)
1520{ 1514{
1521 mutex_lock(&llist_mutex); 1515 mutex_lock(&llist_mutex);
@@ -1642,7 +1636,15 @@ static void NORETURN_ATTR buffering_thread(void)
1642 LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data); 1636 LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data);
1643 shrink_buffer(); 1637 shrink_buffer();
1644 queue_reply(&buffering_queue, 1); 1638 queue_reply(&buffering_queue, 1);
1645 filling |= buffer_handle((int)ev.data, 0); 1639 if (buffer_handle((int)ev.data, 0)) {
1640 filling = true;
1641 }
1642 else if (num_handles > 0 && conf_watermark > 0) {
1643 update_data_counters(NULL);
1644 if (data_counters.useful >= BUF_WATERMARK) {
1645 send_event(BUFFER_EVENT_BUFFER_LOW, NULL);
1646 }
1647 }
1646 break; 1648 break;
1647 1649
1648 case Q_BUFFER_HANDLE: 1650 case Q_BUFFER_HANDLE:
@@ -1699,12 +1701,7 @@ static void NORETURN_ATTR buffering_thread(void)
1699#endif 1701#endif
1700 1702
1701 if (filling) { 1703 if (filling) {
1702 if (data_counters.remaining > 0 && BUF_USED < buffer_len) { 1704 filling = data_counters.remaining > 0 ? fill_buffer() : false;
1703 filling = fill_buffer();
1704 }
1705 else if (data_counters.remaining == 0) {
1706 filling = false;
1707 }
1708 } else if (ev.id == SYS_TIMEOUT) { 1705 } else if (ev.id == SYS_TIMEOUT) {
1709 if (data_counters.useful < BUF_WATERMARK) { 1706 if (data_counters.useful < BUF_WATERMARK) {
1710 /* The buffer is low and we're idle, just watching the levels 1707 /* The buffer is low and we're idle, just watching the levels
diff --git a/apps/buffering.h b/apps/buffering.h
index 2e4cfd3968..ee3e7c9053 100644
--- a/apps/buffering.h
+++ b/apps/buffering.h
@@ -95,7 +95,6 @@ ssize_t bufcuttail(int handle_id, size_t size);
95 * buf_is_handle: is the handle valid? 95 * buf_is_handle: is the handle valid?
96 * buf_pin_handle: Disallow/allow handle movement. Handle may still be removed. 96 * buf_pin_handle: Disallow/allow handle movement. Handle may still be removed.
97 * buf_handle_offset: Get the offset of the first buffered byte from the file 97 * buf_handle_offset: Get the offset of the first buffered byte from the file
98 * buf_request_buffer_handle: Request buffering of a handle
99 * buf_set_base_handle: Tell the buffering thread which handle is currently read 98 * buf_set_base_handle: Tell the buffering thread which handle is currently read
100 * buf_length: Total size of ringbuffer 99 * buf_length: Total size of ringbuffer
101 * buf_used: Total amount of buffer space used (including allocated space) 100 * buf_used: Total amount of buffer space used (including allocated space)
@@ -106,7 +105,6 @@ enum data_type buf_handle_data_type(int handle_id);
106ssize_t buf_handle_remaining(int handle_id); 105ssize_t buf_handle_remaining(int handle_id);
107bool buf_is_handle(int handle_id); 106bool buf_is_handle(int handle_id);
108ssize_t buf_handle_offset(int handle_id); 107ssize_t buf_handle_offset(int handle_id);
109void buf_request_buffer_handle(int handle_id);
110void buf_set_base_handle(int handle_id); 108void buf_set_base_handle(int handle_id);
111size_t buf_length(void); 109size_t buf_length(void);
112size_t buf_used(void); 110size_t buf_used(void);
diff --git a/apps/plugin.c b/apps/plugin.c
index bb326d937b..d9f7c4e24c 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -747,7 +747,6 @@ static const struct plugin_api rockbox_api = {
747 bufcuttail, 747 bufcuttail,
748 748
749 buf_handle_offset, 749 buf_handle_offset,
750 buf_request_buffer_handle,
751 buf_set_base_handle, 750 buf_set_base_handle,
752 buf_used, 751 buf_used,
753#endif 752#endif
diff --git a/apps/plugin.h b/apps/plugin.h
index cdf34e28b1..f15c626667 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -145,12 +145,12 @@ void* plugin_get_buffer(size_t *buffer_size);
145#define PLUGIN_MAGIC 0x526F634B /* RocK */ 145#define PLUGIN_MAGIC 0x526F634B /* RocK */
146 146
147/* increase this every time the api struct changes */ 147/* increase this every time the api struct changes */
148#define PLUGIN_API_VERSION 204 148#define PLUGIN_API_VERSION 205
149 149
150/* update this to latest version if a change to the api struct breaks 150/* update this to latest version if a change to the api struct breaks
151 backwards compatibility (and please take the opportunity to sort in any 151 backwards compatibility (and please take the opportunity to sort in any
152 new function which are "waiting" at the end of the function table) */ 152 new function which are "waiting" at the end of the function table) */
153#define PLUGIN_MIN_API_VERSION 204 153#define PLUGIN_MIN_API_VERSION 205
154 154
155/* plugin return codes */ 155/* plugin return codes */
156/* internal returns start at 0x100 to make exit(1..255) work */ 156/* internal returns start at 0x100 to make exit(1..255) work */
@@ -873,7 +873,6 @@ struct plugin_api {
873 ssize_t (*bufcuttail)(int handle_id, size_t size); 873 ssize_t (*bufcuttail)(int handle_id, size_t size);
874 874
875 ssize_t (*buf_handle_offset)(int handle_id); 875 ssize_t (*buf_handle_offset)(int handle_id);
876 void (*buf_request_buffer_handle)(int handle_id);
877 void (*buf_set_base_handle)(int handle_id); 876 void (*buf_set_base_handle)(int handle_id);
878 size_t (*buf_used)(void); 877 size_t (*buf_used)(void);
879#endif 878#endif