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