[vlc-commits] mmal/vout: Use fixed binding of mmal buffer to picture

Julian Scheel git at videolan.org
Fri Jun 5 15:37:14 CEST 2015


vlc | branch: master | Julian Scheel <julian at jusst.de> | Wed Jun  3 09:50:26 2015 +0200| [88f9688b96667c9d261707755347dd3ff66b1606] | committer: Jean-Baptiste Kempf

mmal/vout: Use fixed binding of mmal buffer to picture

Instead of dynamically allocating a mmal buffer from the mmal buffer pool use
a fixed binding, where the same mmal buffer is used for the whole pictures
lifecycle. This avoids some overhead on picture allocation and simplifies the
code. As the mmal buffer pool is allocated in exactly the same size as the vlc
picture pool there is no drawback doing it this way.

Signed-off-by: Julian Scheel <julian at jusst.de>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88f9688b96667c9d261707755347dd3ff66b1606
---

 modules/hw/mmal/mmal_picture.c |   33 ++-------------------------------
 modules/hw/mmal/mmal_picture.h |    4 ----
 modules/hw/mmal/vout.c         |    8 ++++----
 3 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/modules/hw/mmal/mmal_picture.c b/modules/hw/mmal/mmal_picture.c
index 50ca6d4..584227e 100644
--- a/modules/hw/mmal/mmal_picture.c
+++ b/modules/hw/mmal/mmal_picture.c
@@ -30,43 +30,14 @@
 int mmal_picture_lock(picture_t *picture)
 {
     picture_sys_t *pic_sys = picture->p_sys;
-    int ret = VLC_SUCCESS;
-
-    vlc_mutex_lock(pic_sys->mutex);
-
-    MMAL_BUFFER_HEADER_T *buffer = mmal_queue_timedwait(pic_sys->queue, 2);
-    if (!buffer) {
-        ret = VLC_EGENERIC;
-        goto out;
-    }
+    MMAL_BUFFER_HEADER_T *buffer = pic_sys->buffer;
 
-    mmal_buffer_header_reset(buffer);
     buffer->user_data = picture;
     picture->p[0].p_pixels = buffer->data;
     picture->p[1].p_pixels += (ptrdiff_t)buffer->data;
     picture->p[2].p_pixels += (ptrdiff_t)buffer->data;
 
-    pic_sys->buffer = buffer;
-
     pic_sys->displayed = false;
 
-out:
-    vlc_mutex_unlock(pic_sys->mutex);
-    return ret;
-}
-
-void mmal_picture_unlock(picture_t *picture)
-{
-    picture_sys_t *pic_sys = picture->p_sys;
-    MMAL_BUFFER_HEADER_T *buffer = pic_sys->buffer;
-
-    vlc_mutex_lock(pic_sys->mutex);
-
-    pic_sys->buffer = NULL;
-    if (buffer) {
-        buffer->user_data = NULL;
-        mmal_buffer_header_release(buffer);
-    }
-
-    vlc_mutex_unlock(pic_sys->mutex);
+    return VLC_SUCCESS;
 }
diff --git a/modules/hw/mmal/mmal_picture.h b/modules/hw/mmal/mmal_picture.h
index 68d4bd1..d733f02 100644
--- a/modules/hw/mmal/mmal_picture.h
+++ b/modules/hw/mmal/mmal_picture.h
@@ -34,13 +34,9 @@ struct picture_sys_t {
     vlc_object_t *owner;
 
     MMAL_BUFFER_HEADER_T *buffer;
-    MMAL_QUEUE_T *queue;
-    vlc_mutex_t *mutex;
     bool displayed;
 };
 
-vlc_mutex_t* get_mmal_opaque_mutex(void);
 int mmal_picture_lock(picture_t *picture);
-void mmal_picture_unlock(picture_t *picture);
 
 #endif
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index c58dd3b..ecfcd4d 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -351,8 +351,10 @@ static void Close(vlc_object_t *object)
         picture_pool_Release(sys->picture_pool);
     else
         for (i = 0; i < sys->num_buffers; ++i)
-            if (sys->pictures[i])
+            if (sys->pictures[i]) {
+                mmal_buffer_header_release(sys->pictures[i]->p_sys->buffer);
                 picture_Release(sys->pictures[i]);
+            }
 
     vlc_mutex_destroy(&sys->buffer_mutex);
     vlc_cond_destroy(&sys->buffer_cond);
@@ -497,8 +499,7 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
     for (i = 0; i < sys->num_buffers; ++i) {
         picture_res.p_sys = calloc(1, sizeof(picture_sys_t));
         picture_res.p_sys->owner = (vlc_object_t *)vd;
-        picture_res.p_sys->queue = sys->pool->queue;
-        picture_res.p_sys->mutex = &sys->buffer_mutex;
+        picture_res.p_sys->buffer = mmal_queue_get(sys->pool->queue);
 
         sys->pictures[i] = picture_NewFromResource(&fmt, &picture_res);
         if (!sys->pictures[i]) {
@@ -515,7 +516,6 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
     picture_pool_cfg.picture_count = sys->num_buffers;
     picture_pool_cfg.picture = sys->pictures;
     picture_pool_cfg.lock = mmal_picture_lock;
-    picture_pool_cfg.unlock = mmal_picture_unlock;
 
     sys->picture_pool = picture_pool_NewExtended(&picture_pool_cfg);
     if (!sys->picture_pool) {



More information about the vlc-commits mailing list