Commit graph

19 commits

Author SHA1 Message Date
Michael Sevakis
7e3e9b9289 Stop the BDEBUGF format warnings in buflib.c
Change-Id: I63881da2b857cf4e462f7730f9cd54dc1743fc2f
2012-05-02 17:37:10 -04:00
Michael Sevakis
0d568bb6ce Stop lame warnings about braces and empty body of 'if' statement.
Change-Id: I9f0e3d047a91a8f49d5c64f961f8fff054f37099
2012-05-02 17:30:32 -04:00
Michael Sevakis
da6cebb6b0 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
2012-05-02 17:22:28 -04:00
Thomas Martitz
6c6c476d57 Buflib: Fix handles being possibly moved twice
Author: Boris Gjenero
Fixes: FS#12441, FS#12464

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31359 a1c6a512-1295-4272-9138-f99709370657
2011-12-19 08:08:07 +00:00
Thomas Martitz
f0bab2ff9a Address some weaknesses and bugs of buflib_compact() and make the code prettier. Thanks to Boris Gjenero for his great investigation.
Flyspray: FS#12409
Author: myself

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31101 a1c6a512-1295-4272-9138-f99709370657
2011-12-01 07:02:18 +00:00
Boris Gjenero
d51e598335 FS#12412 : Delete old buffer allocation code which has been replaced by core_alloc, and move buffer setup code to core_alloc.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31088 a1c6a512-1295-4272-9138-f99709370657
2011-11-29 00:42:27 +00:00
Boris Gjenero
bd360b422a In buflib_buffer_shift(), properly update handle->alloc values, which are char * and not union buflib data *
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31066 a1c6a512-1295-4272-9138-f99709370657
2011-11-27 01:40:47 +00:00
Thomas Martitz
2a8eacdbfc Buflib: Make shrinking and buflib_available() smarter.
* shrinking now considers freespace just before the alloc-to-be-shrinked,
  that means less (or sometimes none at all) is taken from the audio buffer.
* core_available() now searches for the best free space, instead of simply the end,
  i.e. it will not return 0 if the audio buffer is allocated and there's free space
  before it. It also runs a compaction to ensure maximum contiguous memory.

audio_buffer_available() is also enhanced. It now considers the 256K reserve buffer,
and returns free buflib space instead if the audio buffer is short.

This all fixes the root problem of FS#12344 (Sansa Clip+: PANIC occurred when
dircache is enabled), that alloced from the audio buffer, even if it was very
short and buflib had many more available as free space before it.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31006 a1c6a512-1295-4272-9138-f99709370657
2011-11-17 17:55:02 +00:00
Thomas Martitz
889690c0f6 Fix audio_get_buffer() implementation on hwcodec, to be similar to the swcodec one. Should make hwcodec bood again.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30737 a1c6a512-1295-4272-9138-f99709370657
2011-10-09 12:30:37 +00:00
Thomas Martitz
aed39dbbaf Protect the move operation of buflib against IRQs.
This makes accessing the buffers with core_get_data() from
interrupt context safe, other buflib functions aren't really safe (yet).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30736 a1c6a512-1295-4272-9138-f99709370657
2011-10-09 12:27:35 +00:00
Thomas Martitz
585eb12348 Buflib: Correct return value of handle_table_shrink() to match comment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30495 a1c6a512-1295-4272-9138-f99709370657
2011-09-10 15:16:15 +00:00
Thomas Martitz
49b64f13e5 Remove obsolete comment
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30488 a1c6a512-1295-4272-9138-f99709370657
2011-09-09 15:44:09 +00:00
Thomas Martitz
f7cff8bd69 Buflib: Stop caching the first unallocated block. It has little benefit but is complicated to keep up-to-date.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30487 a1c6a512-1295-4272-9138-f99709370657
2011-09-09 15:35:14 +00:00
Thomas Martitz
0dcbc6cd5d Buflib: Handle not having enough space for new handles (fixes FS#12265).
Handles are allocated at the end, growing downwards.
The tiny allocations from r30478 broke buflib, since it was assumed that the only shrinkable allocation (the audiobuffer) is the very last allocation.
The tiny allocations however fit into the reserve buffer for new handles, breaking the above assumption, and they can't shrink to make room for handles.

Now, move any allocations before audiobuf (or shrink audiobuf like before) to make room for handles. This also unifies some duplicated code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30486 a1c6a512-1295-4272-9138-f99709370657
2011-09-09 13:33:22 +00:00
Thomas Martitz
daaae99c1c Remove unecessary casting
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30470 a1c6a512-1295-4272-9138-f99709370657
2011-09-07 23:20:12 +00:00
Thomas Martitz
5296af838c Buflib: Clarification about invalid handles
* Enhance allocation function comments to better state the return value and what an invalid value is
* Change clients to check for "< 0" instead of "<= 0" or "== 0"
* Return -1 or -2 depending on the exact failure in buflib_alloc_ex.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30469 a1c6a512-1295-4272-9138-f99709370657
2011-09-07 23:16:29 +00:00
Thomas Martitz
0c4c81620f Fix h100 red and other warnings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30384 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:32:16 +00:00
Thomas Martitz
baa070cca6 GSoC/Buflib: Enable compaction in buflib.
This enables the ability to allocate (and free) memory dynamically
without fragmentation, through compaction. This means allocations can move
and fragmentation be reduced. Most changes are preparing Rockbox for this,
which many times means adding a move callback which can temporarily disable
movement when the corresponding code is in a critical section.

For now, the audio buffer allocation has a central role, because it's the one
having allocated most. This buffer is able to shrink itself, for which it
needs to stop playback for a very short moment. For this,
audio_buffer_available() returns the size of the audio buffer which can
possibly be used by other allocations because the audio buffer can shrink.

lastfm scrobbling and timestretch can now be toggled at runtime without
requiring a reboot.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30381 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:01:45 +00:00
Thomas Martitz
d0b72e2590 GSoC/Buflib: Add buflib memory alocator to the core.
The buflib memory allocator is handle based and can free and
compact, move or resize memory on demand. This allows to effeciently
allocate memory dynamically without an MMU, by avoiding fragmentation
through memory compaction.

This patch adds the buflib library to the core, along with
convinience wrappers to omit the context parameter. Compaction is
not yet enabled, but will be in a later patch. Therefore, this acts as a
replacement for buffer_alloc/buffer_get_buffer() with the benifit of a debug
menu.

See buflib.h for some API documentation.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30380 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:01:33 +00:00