Commit bfe3ffd1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

picture_pool: add enumeration helper

parent 6a493b11
......@@ -95,6 +95,19 @@ VLC_API void picture_pool_Release( picture_pool_t * );
*/
VLC_API picture_t * picture_pool_Get( picture_pool_t * ) VLC_USED;
/**
* Enumerates all pictures in a pool, both free and allocated.
*
* @param cb callback to invoke once for each picture
* @param data opaque data parameter for the callback (first argument)
*
* @note Allocated pictures may be accessed asynchronously by other threads.
* Therefore, only read-only picture parameters can be read by the callback,
* typically picture_t.p_sys.
*/
VLC_API void picture_pool_Enum( picture_pool_t *,
void (*cb)(void *, picture_t *), void *data );
/**
* Forcefully return all pictures in the pool to free/unallocated state.
*
......
......@@ -303,6 +303,7 @@ picture_NewFromResource
picture_pool_Release
picture_pool_Get
picture_pool_GetSize
picture_pool_Enum
picture_pool_New
picture_pool_NewExtended
picture_pool_NewFromFormat
......
......@@ -334,3 +334,12 @@ bool picture_pool_NeedsLocking(const picture_pool_t *pool)
{
return pool->pic_lock != NULL || pool->pic_unlock != NULL;
}
void picture_pool_Enum(picture_pool_t *pool, void (*cb)(void *, picture_t *),
void *opaque)
{
/* NOTE: So far, the pictures table cannot change after the pool is created
* so there is no need to lock the pool mutex here. */
for (unsigned i = 0; i < pool->picture_count; i++)
cb(opaque, pool->picture[i]);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment