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
This commit is contained in:
Michael Sevakis 2011-05-09 21:19:11 +00:00
parent 12e8e43236
commit 5a8f5b8330
4 changed files with 14 additions and 21 deletions

View file

@ -1339,7 +1339,8 @@ static struct memory_handle *prep_bufdata(int handle_id, size_t *size,
if (h->filerem > 0 && avail < realsize) { if (h->filerem > 0 && avail < realsize) {
/* Data isn't ready. Request buffering */ /* 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 */ /* Wait for the data to be ready */
do do
{ {
@ -1486,7 +1487,6 @@ SECONDARY EXPORTED FUNCTIONS
============================ ============================
buf_handle_offset buf_handle_offset
buf_request_buffer_handle
buf_set_base_handle buf_set_base_handle
buf_handle_data_type buf_handle_data_type
buf_is_handle buf_is_handle
@ -1510,12 +1510,6 @@ ssize_t buf_handle_offset(int handle_id)
return h->offset; 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) void buf_set_base_handle(int handle_id)
{ {
mutex_lock(&llist_mutex); mutex_lock(&llist_mutex);
@ -1642,7 +1636,15 @@ static void NORETURN_ATTR buffering_thread(void)
LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data); LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data);
shrink_buffer(); shrink_buffer();
queue_reply(&buffering_queue, 1); 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; break;
case Q_BUFFER_HANDLE: case Q_BUFFER_HANDLE:
@ -1699,12 +1701,7 @@ static void NORETURN_ATTR buffering_thread(void)
#endif #endif
if (filling) { if (filling) {
if (data_counters.remaining > 0 && BUF_USED < buffer_len) { filling = data_counters.remaining > 0 ? fill_buffer() : false;
filling = fill_buffer();
}
else if (data_counters.remaining == 0) {
filling = false;
}
} else if (ev.id == SYS_TIMEOUT) { } else if (ev.id == SYS_TIMEOUT) {
if (data_counters.useful < BUF_WATERMARK) { if (data_counters.useful < BUF_WATERMARK) {
/* The buffer is low and we're idle, just watching the levels /* The buffer is low and we're idle, just watching the levels

View file

@ -95,7 +95,6 @@ ssize_t bufcuttail(int handle_id, size_t size);
* buf_is_handle: is the handle valid? * buf_is_handle: is the handle valid?
* buf_pin_handle: Disallow/allow handle movement. Handle may still be removed. * buf_pin_handle: Disallow/allow handle movement. Handle may still be removed.
* buf_handle_offset: Get the offset of the first buffered byte from the file * buf_handle_offset: Get the offset of the first buffered byte from the file
* buf_request_buffer_handle: Request buffering of a handle
* buf_set_base_handle: Tell the buffering thread which handle is currently read * buf_set_base_handle: Tell the buffering thread which handle is currently read
* buf_length: Total size of ringbuffer * buf_length: Total size of ringbuffer
* buf_used: Total amount of buffer space used (including allocated space) * 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);
ssize_t buf_handle_remaining(int handle_id); ssize_t buf_handle_remaining(int handle_id);
bool buf_is_handle(int handle_id); bool buf_is_handle(int handle_id);
ssize_t buf_handle_offset(int handle_id); ssize_t buf_handle_offset(int handle_id);
void buf_request_buffer_handle(int handle_id);
void buf_set_base_handle(int handle_id); void buf_set_base_handle(int handle_id);
size_t buf_length(void); size_t buf_length(void);
size_t buf_used(void); size_t buf_used(void);

View file

@ -747,7 +747,6 @@ static const struct plugin_api rockbox_api = {
bufcuttail, bufcuttail,
buf_handle_offset, buf_handle_offset,
buf_request_buffer_handle,
buf_set_base_handle, buf_set_base_handle,
buf_used, buf_used,
#endif #endif

View file

@ -145,12 +145,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 204 #define PLUGIN_API_VERSION 205
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 204 #define PLUGIN_MIN_API_VERSION 205
/* plugin return codes */ /* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */ /* internal returns start at 0x100 to make exit(1..255) work */
@ -873,7 +873,6 @@ struct plugin_api {
ssize_t (*bufcuttail)(int handle_id, size_t size); ssize_t (*bufcuttail)(int handle_id, size_t size);
ssize_t (*buf_handle_offset)(int handle_id); ssize_t (*buf_handle_offset)(int handle_id);
void (*buf_request_buffer_handle)(int handle_id);
void (*buf_set_base_handle)(int handle_id); void (*buf_set_base_handle)(int handle_id);
size_t (*buf_used)(void); size_t (*buf_used)(void);
#endif #endif