[vlc-devel] [PATCH 11/14] mmal/deinterlace: Do not filter the same picture twice
Julian Scheel
julian at jusst.de
Wed Jun 3 09:50:36 CEST 2015
If the same picture, containing the same buffer header without being
re-acquired in the meantime, is sent to image_fx twice it will portentially
cause a double free within the mmal core as it destroys the internal
refcounting. Use the same guarding mechanism which is already in place in
mmal/vout to ensure this is not happening at any point.
Signed-off-by: Julian Scheel <julian at jusst.de>
---
modules/hw/mmal/deinterlace.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index d158b71..0a56a94 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -337,16 +337,22 @@ static picture_t *deinterlace(filter_t *filter, picture_t *picture)
buffer->pts = picture->date;
buffer->cmd = 0;
- vlc_mutex_lock(&sys->buffer_cond_mutex);
- status = mmal_port_send_buffer(sys->input, buffer);
- if (status != MMAL_SUCCESS) {
- msg_Err(filter, "Failed to send buffer to input port (status=%"PRIx32" %s)",
- status, mmal_status_to_string(status));
+ if (!picture->p_sys->displayed) {
+ vlc_mutex_lock(&sys->buffer_cond_mutex);
+ status = mmal_port_send_buffer(sys->input, buffer);
+ if (status != MMAL_SUCCESS) {
+ msg_Err(filter, "Failed to send buffer to input port (status=%"PRIx32" %s)",
+ status, mmal_status_to_string(status));
+ picture_Release(picture);
+ } else {
+ picture->p_sys->displayed = true;
+ atomic_fetch_add(&sys->input_in_transit, 1);
+ vlc_cond_signal(&sys->buffer_cond);
+ }
+ vlc_mutex_unlock(&sys->buffer_cond_mutex);
} else {
- atomic_fetch_add(&sys->input_in_transit, 1);
- vlc_cond_signal(&sys->buffer_cond);
+ picture_Release(picture);
}
- vlc_mutex_unlock(&sys->buffer_cond_mutex);
/*
* Send output buffers
--
2.4.0
More information about the vlc-devel
mailing list