forked from len0rd/rockbox
buflib: Try harder in buflib_alloc_maximum().
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
This commit is contained in:
parent
9f878b105d
commit
d25a512caf
2 changed files with 17 additions and 4 deletions
|
@ -111,10 +111,10 @@ struct buflib_callbacks {
|
|||
void (*sync_callback)(int handle, bool sync_on);
|
||||
};
|
||||
|
||||
#define BUFLIB_SHRINK_POS_MASK ((1<<0|1<<1)<<30)
|
||||
#define BUFLIB_SHRINK_SIZE_MASK (~BUFLIB_SHRINK_POS_MASK)
|
||||
#define BUFLIB_SHRINK_POS_FRONT (1u<<31)
|
||||
#define BUFLIB_SHRINK_POS_BACK (1u<<30)
|
||||
#define BUFLIB_SHRINK_POS_MASK (BUFLIB_SHRINK_POS_FRONT|BUFLIB_SHRINK_POS_BACK)
|
||||
|
||||
/**
|
||||
* Possible return values for the callbacks, some of them can cause
|
||||
|
@ -193,8 +193,10 @@ int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name,
|
|||
* will allow buflib to permit allocations by shrinking the buffer returned by
|
||||
* this function.
|
||||
*
|
||||
* Note that this currently gives whatever buflib_available() returns. However,
|
||||
* do not depend on this behavior, it may change.
|
||||
* Note that this might return many more bytes than buflib_available() or
|
||||
* buflib_allocatable() return, because it agressively compacts the pool
|
||||
* and even shrinks other allocations. However, do not depend on this behavior,
|
||||
* it may change.
|
||||
*
|
||||
* name: A string identifier giving this allocation a name
|
||||
* size: The actual size will be returned into size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue