*****************************************************************************/
struct picture_gc_sys_t {
picture_pool_t *pool;
-
/* Saved release */
void (*destroy)(picture_t *);
void *destroy_sys;
-
- /* */
- int (*lock)(picture_t *);
- void (*unlock)(picture_t *);
-
/* */
atomic_bool zombie;
int64_t tick;
picture_t **picture;
bool *picture_reserved;
+ int (*pic_lock)(picture_t *);
+ void (*pic_unlock)(picture_t *);
unsigned refs;
vlc_mutex_t lock;
};
-static int Lock(picture_t *);
-static void Unlock(picture_t *);
-
static void Release(picture_pool_t *pool)
{
bool destroy;
picture_gc_sys_t *gc_sys = picture->gc.p_sys;
picture_pool_t *pool = gc_sys->pool;
- Unlock(picture);
+ if (pool->pic_unlock != NULL)
+ pool->pic_unlock(picture);
if (!atomic_load(&gc_sys->zombie))
return;
if (!pool)
return NULL;
+ pool->pic_lock = cfg->lock;
+ pool->pic_unlock = cfg->unlock;
+
/*
* NOTE: When a pooled picture is released, it must be returned to the list
* of available pictures from its pool, rather than destroyed.
gc_sys->pool = pool;
gc_sys->destroy = picture->gc.pf_destroy;
gc_sys->destroy_sys = picture->gc.p_sys;
- gc_sys->lock = cfg->lock;
- gc_sys->unlock = cfg->unlock;
atomic_init(&gc_sys->zombie, false);
gc_sys->tick = 0;
if (!pool)
return NULL;
+ pool->pic_lock = master->pic_lock;
+ pool->pic_unlock = master->pic_unlock;
+
int found = 0;
for (int i = 0; i < master->picture_count && found < count; i++) {
if (master->picture_reserved[i])
if (atomic_load(&picture->gc.refcount) > 0)
continue;
- if (Lock(picture))
+ if (pool->pic_lock != NULL && pool->pic_lock(picture) != 0)
continue;
/* */
continue;
picture_t *picture = pool->picture[i];
- if (atomic_load(&picture->gc.refcount) > 0)
- Unlock(picture);
+ if (atomic_load(&picture->gc.refcount) > 0) {
+ if (pool->pic_unlock != NULL)
+ pool->pic_unlock(picture);
+ }
atomic_store(&picture->gc.refcount, 0);
}
}
if (oldest == NULL)
return; /* Cannot fix! */
- if (atomic_load(&oldest->gc.refcount) > 0)
- Unlock(oldest);
+ if (atomic_load(&oldest->gc.refcount) > 0) {
+ if (pool->pic_unlock != NULL)
+ pool->pic_unlock(oldest);
+ }
atomic_store(&oldest->gc.refcount, 0);
}
{
return pool->picture_count;
}
-
-static int Lock(picture_t *picture)
-{
- picture_gc_sys_t *gc_sys = picture->gc.p_sys;
- if (gc_sys->lock)
- return gc_sys->lock(picture);
- return VLC_SUCCESS;
-}
-
-static void Unlock(picture_t *picture)
-{
- picture_gc_sys_t *gc_sys = picture->gc.p_sys;
- if (gc_sys->unlock)
- gc_sys->unlock(picture);
-}