forked from len0rd/rockbox
Add comments, and prevent a nearly impossible wrapping bug. There's always enough space for the next whole audio chunk now, so it's faster too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8678 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3a37faee57
commit
3bbd93b260
1 changed files with 11 additions and 8 deletions
|
|
@ -717,7 +717,8 @@ static bool prepare_insert(size_t length)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (audiobuffer_free < length && !crossfade_active)
|
||||
/* Need to save PCMBUF_MIN_CHUNK to prevent wrapping overwriting */
|
||||
if (audiobuffer_free < length + PCMBUF_MIN_CHUNK && !crossfade_active)
|
||||
{
|
||||
pcmbuf_boost(false);
|
||||
return false;
|
||||
|
|
@ -750,16 +751,18 @@ void* pcmbuf_request_buffer(size_t length, size_t *realsize)
|
|||
if(prepare_insert(length))
|
||||
{
|
||||
size_t audiobuffer_index = audiobuffer_pos + audiobuffer_fillpos;
|
||||
if (pcmbuf_size - audiobuffer_index < PCMBUF_MIN_CHUNK) {
|
||||
pcmbuf_flush_fillpos();
|
||||
audiobuffer_pos = 0;
|
||||
*realsize = MIN(length, pcmbuf_size);
|
||||
return &audiobuffer[0];
|
||||
*realsize = length;
|
||||
if (pcmbuf_size - audiobuffer_index >= PCMBUF_MIN_CHUNK)
|
||||
{
|
||||
/* Usual case, there's space here */
|
||||
return &audiobuffer[audiobuffer_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
*realsize = MIN(length, pcmbuf_size - audiobuffer_index);
|
||||
return &audiobuffer[audiobuffer_index];
|
||||
/* Flush and wrap the buffer */
|
||||
pcmbuf_flush_fillpos();
|
||||
audiobuffer_pos = 0;
|
||||
return &audiobuffer[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue