[vlc-commits] mmal/deinterlace: Add locking to port callbacks

Julian Scheel git at videolan.org
Tue Jan 20 07:08:08 CET 2015


vlc | branch: master | Julian Scheel <julian at jusst.de> | Mon Jan 19 11:30:30 2015 +0100| [0b7fff93d3baa47af5776a0ff57573fc45c59533] | committer: Rémi Denis-Courmont

mmal/deinterlace: Add locking to port callbacks

The in- and ouput port callbacks lead to access on the mmal pools, which are
not thread-safe. To deal with this the sys->mutex is used to lock against
usage of the mmal pools from the main thread.

Signed-off-by: Julian Scheel <julian at jusst.de>
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 modules/hw/mmal/deinterlace.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index e6f54e1..edfdec8 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -479,11 +479,14 @@ static void input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
 {
     picture_t *picture = (picture_t *)buffer->user_data;
     filter_t *filter = (filter_t *)port->userdata;
+    filter_sys_t *sys = filter->p_sys;
 
     buffer->user_data = NULL;
+    vlc_mutex_lock(&sys->mutex);
     mmal_buffer_header_release(buffer);
     if (picture)
         picture_Release(picture);
+    vlc_mutex_unlock(&sys->mutex);
 }
 
 static void output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
@@ -492,6 +495,7 @@ static void output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
     filter_sys_t *sys = filter->p_sys;
     picture_t *picture;
 
+    vlc_mutex_lock(&sys->mutex);
     if (buffer->cmd == 0) {
         if (buffer->length > 0) {
             mmal_queue_put(sys->filtered_pictures, buffer);
@@ -508,4 +512,5 @@ static void output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
     } else {
         mmal_buffer_header_release(buffer);
     }
+    vlc_mutex_unlock(&sys->mutex);
 }



More information about the vlc-commits mailing list