summaryrefslogtreecommitdiff
path: root/firmware/include/buflib.h (follow)
Commit message (Collapse)AuthorAge
* Improve core_alloc() / buflib_alloc() documentationThomas Jarosch2015-01-02
| | | | | | | | | | | | | | | | | | | | Document the fact that buffers are movable by default. Care must be taken to not pass them to functions that yield(). Also clarify other things: - Passing NULL as "ops" to buflib_alloc_ex() causes buffers to be movable by default (but not shrinkable). - If you want shrinkable buffers during compaction, you have to provide a shrink callback. - To disable buffer movement, you have to pass NULL for the move_callback inside the callback structure. - The concept of default callbacks was removed long ago, remove the only reference of it. Change-Id: I3bf0ea6b08b507d80a19f3c2c835aca32b3f7800
* Document 'union buflib_data'Thomas Jarosch2014-12-29
| | | | Change-Id: Ia98fa8e7887338d6c0b7a5795a0ae5c7a13014ba
* Two more typo fixesThomas Jarosch2014-12-27
| | | | Change-Id: Id3ec7c1da356cb7c617a1d9ad57c9e0ae9fa6611
* Fix typos in documentationThomas Jarosch2014-12-27
| | | | Change-Id: I3c7e204bcf67bf0004314fe4b2aec98cae145273
* buflib: Add a define telling the per-alloc overhead.Thomas Martitz2014-02-02
| | | | | | | | This allows buflib clients to more accurately estimate the total memory usage. It's still not 100% accurate because the handle table grows in blocks, thus buflib might use more memory that caused by allocations directly. Change-Id: I68338bb94f510ad188fcb588aebf895b5f9197c5
* buflib: Properly support allocations without any name, to avoid wasting spaceThomas Martitz2014-02-02
| | | | | | in micro-allocation scenarios. Change-Id: I97a065bcfba8e0fda9b1670445e839e267c769c8
* buflib: Check the validity of of handles passed to buflib_get_data() in ↵Thomas Martitz2014-02-02
| | | | | | DEBUG builds. Change-Id: Ic274bfb4a8e1a1a10f9a54186b9173dbc0faa4c8
* buflib: Add crc field protecting buflib cookie integrityMarcin Bukat2014-01-16
| | | | | | | | | | | | | | | This should catch the case of buffer misuse which results in corrupted cookie of next allocation. The check is performed on move_block() so it may be a bit late. There is buflib_check_valid() provided which checks the integrity of all cookies for given context. On DEBUG build with --sdl-thread this check is carried out for core_ctx on every context switch to catch problems earlier. Change-Id: I999d4576084592394e3dbd3bdf0f32935ff5f601 Reviewed-on: http://gerrit.rockbox.org/711 Reviewed-by: Thomas Martitz <kugel@rockbox.org>
* buflib: Add buflib_context_relocate().Thomas Martitz2013-12-22
| | | | | | | | | | | | | | This function relocates a buflib back buffer, updating pointers in struct buflib_context. It does not move any data by itself. The intended use-case is buflib-on-buflib, where a buflib back buffer is allocated with buflib and attempted to be moved. The move_callback() can call this and return BUFLIB_CB_OK on success. No move_callback() is called for the subordinate buflib buffer, therefore it must not contain non-movable allocations. The caller is generally responsible moving the data and all its implications. Change-Id: I869219f9cff786a172c9e917a5f34470073892e6
* buflib: Try harder in buflib_alloc_maximum().Thomas Martitz2013-12-22
| | | | | | | | This function will now ask shrinkable allocations to give up all of their memory. With future support of playback.c this can be used as a safe replacement for audio_get_buffer(). Change-Id: I290a51d2c75254e66baf5698c41dc444dea6247a
* buflib: Change buflib_available() and add buflib_allocatable().Thomas Martitz2013-07-07
| | | | | | | | | | | | | | | buflib_allocatable() is what buflib_available() was before (it was in fact simply renamed). It returns the largest contiguous block of memory. This can be allocated and will definitely succeed, although larger allocations may also succeed if the buffer can be compacted and shrinked. buflib_available() now counts all free bytes, contiguous or not. This better matches the description and how the caller use it. Change-Id: I511e4eb5f4cf1821d957b3f4ef8a685ce40fe289 Reviewed-on: http://gerrit.rockbox.org/481 Reviewed-by: Thomas Martitz <kugel@rockbox.org> Tested-by: Thomas Martitz <kugel@rockbox.org>
* Use buflib for the allocation of voice PCM resources.Michael Sevakis2012-05-02
| | | | | | | | | | | | | 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
* Buflib: Stop caching the first unallocated block. It has little benefit but ↵Thomas Martitz2011-09-09
| | | | | | is complicated to keep up-to-date. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30487 a1c6a512-1295-4272-9138-f99709370657
* Buflib: Clarification about invalid handlesThomas Martitz2011-09-07
| | | | | | | | * 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
* GSoC/Buflib: Add buflib memory alocator to the core.Thomas Martitz2011-08-30
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