Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From cfb432fcd8868c7a4f32010c61e47e2bf0ff80c6 Mon Sep 17 00:00:00 2001 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 2 | From: =?UTF-8?q?Enrique=20Oca=C3=B1a=20Gonz=C3=A1lez?= <eocanha@igalia.com> |
| 3 | Date: Mon, 25 May 2015 14:53:35 +0200 |
| 4 | Subject: [PATCH] Don't try to acquire buffer when src pad isn't active |
| 5 | |
| 6 | This solves a race condition when setting the pipeline from PAUSE to |
| 7 | NULL while the decoder loop is still running. Without this patch, the |
| 8 | thread which interacts with the decode sink pad gets blocked here: |
| 9 | |
| 10 | gst_element_change_state() |
| 11 | gst_element_change_state_func() |
| 12 | gst_element_pads_activate() --> Deactivating pads |
| 13 | activate_pads() |
| 14 | gst_pad_set_active() |
| 15 | gst_pad_activate_mode() |
| 16 | post_activate() |
| 17 | GST_PAD_STREAM_LOCK() |
| 18 | |
| 19 | while gst_omx_port_acquire_buffer() gets stalled forever in |
| 20 | gst_omx_component_wait_message() waiting for a message that will never |
| 21 | arrive: |
| 22 | |
| 23 | gst_omx_video_dec_loop() |
| 24 | gst_omx_port_acquire_buffer() |
| 25 | gst_omx_component_wait_message() |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 27 | --- |
| 28 | omx/gstomxvideodec.c | 5 +++++ |
| 29 | 1 file changed, 5 insertions(+) |
| 30 | |
| 31 | diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | index d12ee8f..fb0100a 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 33 | --- a/omx/gstomxvideodec.c |
| 34 | +++ b/omx/gstomxvideodec.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | @@ -1250,6 +1250,11 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 36 | GstClockTimeDiff deadline; |
| 37 | OMX_ERRORTYPE err; |
| 38 | |
| 39 | + if (!gst_pad_is_active(GST_VIDEO_DECODER_SRC_PAD (self))) { |
| 40 | + GST_DEBUG_OBJECT (self, "Src pad not active, not acquiring buffer and flushing instead"); |
| 41 | + goto flushing; |
| 42 | + } |
| 43 | + |
| 44 | #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL) |
| 45 | port = self->eglimage ? self->egl_out_port : self->dec_out_port; |
| 46 | #else |