forked from len0rd/rockbox
More try to fix 8077, BUF_USED is not a good way to determine if the buffer is healthy any more, we'll need a enw way if we need to resurrect yield_codec later
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15447 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e247230e0d
commit
aabd6885bf
1 changed files with 14 additions and 30 deletions
|
@ -515,33 +515,6 @@ These functions are used by the buffering thread to manage buffer space.
|
|||
*/
|
||||
|
||||
|
||||
static inline bool filebuf_is_lowdata(void)
|
||||
{
|
||||
return BUF_USED < BUFFERING_CRITICAL_LEVEL;
|
||||
}
|
||||
|
||||
/* Yield to the codec thread for as long as possible if it is in need of data.
|
||||
Return true if the caller should break to let the buffering thread process
|
||||
new queue events */
|
||||
static bool yield_codec(void)
|
||||
{
|
||||
yield();
|
||||
|
||||
if (!queue_empty(&buffering_queue))
|
||||
return true;
|
||||
|
||||
while (pcmbuf_is_lowdata() && !filebuf_is_lowdata())
|
||||
{
|
||||
sleep(2);
|
||||
trigger_cpu_boost();
|
||||
|
||||
if (!queue_empty(&buffering_queue))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Buffer data for the given handle.
|
||||
Return whether or not the buffering should continue explicitly. */
|
||||
static bool buffer_handle(int handle_id)
|
||||
|
@ -618,9 +591,20 @@ static bool buffer_handle(int handle_id)
|
|||
h->available += rc;
|
||||
h->filerem -= rc;
|
||||
|
||||
/* Stop buffering if new queue events have arrived */
|
||||
if (breakable && yield_codec())
|
||||
break;
|
||||
yield();
|
||||
/* If this is a large file, see if we need to breakor give the codec
|
||||
* more time */
|
||||
if (breakable) {
|
||||
if (!queue_empty(&buffering_queue))
|
||||
break;
|
||||
if (pcmbuf_is_lowdata())
|
||||
{
|
||||
sleep(2);
|
||||
trigger_cpu_boost();
|
||||
if (!queue_empty(&buffering_queue))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (h->filerem == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue