From ed8f57fa284b543655c3396391b45447bf2ad2a4 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Fri, 28 Jul 2023 08:48:10 +0200 Subject: [PATCH] picture_pool: remove unused Reserve function It was useful in the past when the vout was allocating buffers once. We don't need this trick anymore. --- include/vlc_picture_pool.h | 18 ------------------ src/libvlccore.sym | 1 - src/misc/picture_pool.c | 28 ---------------------------- src/test/picture_pool.c | 27 +-------------------------- 4 files changed, 1 insertion(+), 73 deletions(-) diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h index 0c71e9f5eb..efa2a5f1eb 100644 --- a/include/vlc_picture_pool.h +++ b/include/vlc_picture_pool.h @@ -104,22 +104,4 @@ VLC_API picture_t * picture_pool_Get( picture_pool_t * ) VLC_USED; */ VLC_API picture_t *picture_pool_Wait(picture_pool_t *) VLC_USED; -/** - * Reserves pictures from a pool and creates a new pool with those. - * - * When the new pool is released, pictures are returned to the master pool. - * If the master pool was already released, pictures will be destroyed. - * - * @param pool A pool from ::picture_pool_New or ::picture_pool_NewFromFormat - * @param count number of picture to reserve - * - * @return the new pool, or NULL if there were not enough pictures available - * or on error - * - * @note This function is thread-safe (but it might return NULL if other - * threads have already allocated too many pictures). - */ -VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *pool, unsigned count) -VLC_USED; - #endif /* VLC_PICTURE_POOL_H */ diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 3284d6f6dd..3b9569b961 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -335,7 +335,6 @@ picture_pool_Release picture_pool_Get picture_pool_New picture_pool_NewFromFormat -picture_pool_Reserve picture_pool_Wait picture_Reset picture_Setup diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c index 3a0c6eac84..78bba2d292 100644 --- a/src/misc/picture_pool.c +++ b/src/misc/picture_pool.c @@ -153,34 +153,6 @@ error: return NULL; } -picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned count) -{ - if (count == 0) - vlc_assert_unreachable(); - if (unlikely(count > POOL_MAX)) - return NULL; - - picture_t *picture[POOL_MAX]; - unsigned i; - - for (i = 0; i < count; i++) { - picture[i] = picture_pool_Get(master); - if (picture[i] == NULL) - goto error; - } - - picture_pool_t *pool = picture_pool_New(count, picture); - if (!pool) - goto error; - - return pool; - -error: - while (i > 0) - picture_Release(picture[--i]); - return NULL; -} - picture_t *picture_pool_Get(picture_pool_t *pool) { diff --git a/src/test/picture_pool.c b/src/test/picture_pool.c index 9b43c25fdd..78acf39540 100644 --- a/src/test/picture_pool.c +++ b/src/test/picture_pool.c @@ -35,7 +35,7 @@ const char vlc_module_name[] = "test_picture_pool"; static video_format_t fmt; -static picture_pool_t *pool, *reserve; +static picture_pool_t *pool; static void test(bool zombie) { @@ -52,9 +52,6 @@ static void test(bool zombie) for (unsigned i = 0; i < PICTURES; i++) assert(picture_pool_Get(pool) == NULL); - // Reserve currently assumes that all pictures are free (or reserved). - //assert(picture_pool_Reserve(pool, 1) == NULL); - for (unsigned i = 0; i < PICTURES / 2; i++) picture_Hold(pics[i]); @@ -79,28 +76,10 @@ static void test(bool zombie) assert(pics[i] != NULL); } - for (unsigned i = 0; i < PICTURES; i++) - picture_Release(pics[i]); - - reserve = picture_pool_Reserve(pool, PICTURES / 2); - assert(reserve != NULL); - - for (unsigned i = 0; i < PICTURES / 2; i++) { - pics[i] = picture_pool_Get(pool); - assert(pics[i] != NULL); - } - - for (unsigned i = PICTURES / 2; i < PICTURES; i++) { - assert(picture_pool_Get(pool) == NULL); - pics[i] = picture_pool_Get(reserve); - assert(pics[i] != NULL); - } - if (!zombie) for (unsigned i = 0; i < PICTURES; i++) picture_Release(pics[i]); - picture_pool_Release(reserve); picture_pool_Release(pool); if (zombie) @@ -115,10 +94,6 @@ int main(void) pool = picture_pool_NewFromFormat(&fmt, PICTURES); assert(pool != NULL); - reserve = picture_pool_Reserve(pool, PICTURES / 2); - assert(reserve != NULL); - - picture_pool_Release(reserve); picture_pool_Release(pool); test(false);