[vlc-devel] [PATCH 5/5] picture_pool: don't lock/unlock pictures anymore

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 26 09:14:53 CET 2019


We can no longer use GPU pictures in CPU code via the pools. It has to be done
explicitly and only if the mapped memory doesn't change during the lifetime of
the picture.
---
 src/misc/picture_pool.c | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index d6717d2490..cc679a12f6 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -39,8 +39,6 @@
 static_assert ((POOL_MAX & (POOL_MAX - 1)) == 0, "Not a power of two");
 
 struct picture_pool_t {
-    int       (*pic_lock)(picture_t *);
-    void      (*pic_unlock)(picture_t *);
     vlc_mutex_t lock;
     vlc_cond_t  wait;
 
@@ -77,8 +75,6 @@ static void picture_pool_ReleasePicture(picture_t *clone)
     unsigned offset = sys & (POOL_MAX - 1);
     picture_t *picture = pool->picture[offset];
 
-    if (pool->pic_unlock != NULL)
-        pool->pic_unlock(picture);
     picture_Release(picture);
 
     vlc_mutex_lock(&pool->lock);
@@ -189,33 +185,18 @@ error:
 
 picture_t *picture_pool_Get(picture_pool_t *pool)
 {
-    unsigned long long available;
-
     vlc_mutex_lock(&pool->lock);
     assert(pool->refs > 0);
-    available = pool->available;
 
-    while (available != 0)
+    if (pool->available != 0 && likely(!pool->canceled))
     {
-        int i = ctz(available);
-
-        if (unlikely(pool->canceled))
-            break;
+        int i = ctz(pool->available);
 
         pool->available &= ~(1ULL << i);
         vlc_mutex_unlock(&pool->lock);
-        available &= ~(1ULL << i);
-
-        picture_t *picture = pool->picture[i];
-
-        if (pool->pic_lock != NULL && pool->pic_lock(picture) != VLC_SUCCESS) {
-            vlc_mutex_lock(&pool->lock);
-            pool->available |= 1ULL << i;
-            continue;
-        }
 
         picture_t *clone = picture_pool_ClonePicture(pool, i);
-        if (clone != NULL) {
+        if (likely(clone != NULL)) {
             assert(clone->p_next == NULL);
             atomic_fetch_add_explicit(&pool->refs, 1, memory_order_relaxed);
         }
@@ -247,14 +228,6 @@ picture_t *picture_pool_Wait(picture_pool_t *pool)
 
     picture_t *picture = pool->picture[i];
 
-    if (pool->pic_lock != NULL && pool->pic_lock(picture) != VLC_SUCCESS) {
-        vlc_mutex_lock(&pool->lock);
-        pool->available |= 1ULL << i;
-        vlc_cond_signal(&pool->wait);
-        vlc_mutex_unlock(&pool->lock);
-        return NULL;
-    }
-
     picture_t *clone = picture_pool_ClonePicture(pool, i);
     if (clone != NULL) {
         assert(clone->p_next == NULL);
-- 
2.17.1



More information about the vlc-devel mailing list