1
0
Fork 0
forked from len0rd/rockbox

Use buflib for the allocation of voice PCM resources.

Buffers are not allocated and thread is not created until the first
call where voice is required.

Adds a different callback (sync_callback) to buflib so that other
sorts of synchonization are possible, such as briefly locking-out the
PCM callback for a buffer move. It's sort of a messy addition but it
is needed so voice decoding won't have to be stopped when its buffer
is moved.

Change-Id: I4d4d8c35eed5dd15fb7ee7df9323af3d036e92b3
This commit is contained in:
Michael Sevakis 2012-05-02 17:22:28 -04:00
parent 3d3a144cf6
commit da6cebb6b0
13 changed files with 244 additions and 132 deletions

View file

@ -210,23 +210,27 @@ move_block(struct buflib_context* ctx, union buflib_data* block, int shift)
/* disable IRQs to make accessing the buffer from interrupt context safe. */
/* protect the move callback, as a cached global pointer might be updated
* in it. and protect "tmp->alloc = new_start" for buflib_get_data() */
disable_irq();
/* call the callback before moving */
if (ops)
if (ops && ops->sync_callback)
ops->sync_callback(handle, true);
else
disable_irq();
bool retval = false;
if (!ops || ops->move_callback(handle, tmp->alloc, new_start)
!= BUFLIB_CB_CANNOT_MOVE)
{
if (ops->move_callback(handle, tmp->alloc, new_start)
== BUFLIB_CB_CANNOT_MOVE)
{
enable_irq();
return false;
}
tmp->alloc = new_start; /* update handle table */
memmove(new_block, block, block->val * sizeof(union buflib_data));
retval = true;
}
tmp->alloc = new_start; /* update handle table */
memmove(new_block, block, block->val * sizeof(union buflib_data));
if (ops && ops->sync_callback)
ops->sync_callback(handle, false);
else
enable_irq();
enable_irq();
return true;
return retval;
}
/* Compact allocations and handle table, adjusting handle pointers as needed.