vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Mon Nov 3 19:55:41 2014 +0200| [bfe3ffd17ebfbae8ce2ae27f17090517c79e7a01] | committer: Rémi Denis-Courmont
picture_pool: add enumeration helper > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bfe3ffd17ebfbae8ce2ae27f17090517c79e7a01 --- include/vlc_picture_pool.h | 13 +++++++++++++ src/libvlccore.sym | 1 + src/misc/picture_pool.c | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h index 72278c9..aa51678 100644 --- a/include/vlc_picture_pool.h +++ b/include/vlc_picture_pool.h @@ -96,6 +96,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. * * @warning This can only be called when it is known that all pending diff --git a/src/libvlccore.sym b/src/libvlccore.sym index b53ad9d..10e036a 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -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 diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c index dac7ef6..2d52517 100644 --- a/src/misc/picture_pool.c +++ b/src/misc/picture_pool.c @@ -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]); +} _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
