diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-05-02 17:22:28 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2012-05-02 17:22:28 -0400 |
commit | da6cebb6b0b17b4a75a2bd4f51b7cf70b5dafe40 (patch) | |
tree | df0eb18120c38ec7b08d3ae1e0837f0781065e87 /firmware/buflib.c | |
parent | 3d3a144cf68186fd34f7bf11181b7757c7a6018d (diff) |
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
Diffstat (limited to 'firmware/buflib.c')
-rw-r--r-- | firmware/buflib.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c index 2d4b4b8bb2..f73c8ce4fb 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c @@ -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. |