[vlc-devel] [PATCH 11/14] mmal/deinterlace: Add locking to port callbacks

Julian Scheel julian at jusst.de
Mon Jan 19 11:30:30 CET 2015


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>
---
 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);
 }
-- 
2.2.1




More information about the vlc-devel mailing list