blob: c8af7da0e0579b5c30a1fbe8871945fe6635c02b [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001From 160181edf5fc73288abfe99fa04de4a550cd9c65 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 11 Feb 2016 12:53:20 -0800
Patrick Williams8b8bc412016-08-17 15:02:23 -05004Subject: [PATCH] Don't try to acquire buffer when src pad isn't active
5
Brad Bishop15ae2502019-06-18 21:44:24 -04006From: =?UTF-8?q?Enrique=20Oca=C3=B1a=20Gonz=C3=A1lez?= <eocanha@igalia.com>
7
Patrick Williams8b8bc412016-08-17 15:02:23 -05008This solves a race condition when setting the pipeline from PAUSE to
9NULL while the decoder loop is still running. Without this patch, the
10thread 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
21while gst_omx_port_acquire_buffer() gets stalled forever in
22gst_omx_component_wait_message() waiting for a message that will never
23arrive:
24
25 gst_omx_video_dec_loop()
26 gst_omx_port_acquire_buffer()
27 gst_omx_component_wait_message()
Brad Bishop316dfdd2018-06-25 12:45:53 -040028
Patrick Williams8b8bc412016-08-17 15:02:23 -050029---
30 omx/gstomxvideodec.c | 5 +++++
31 1 file changed, 5 insertions(+)
32
33diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c
Brad Bishop15ae2502019-06-18 21:44:24 -040034index abe6e30..c4dc33f 100644
Patrick Williams8b8bc412016-08-17 15:02:23 -050035--- a/omx/gstomxvideodec.c
36+++ b/omx/gstomxvideodec.c
Brad Bishop15ae2502019-06-18 21:44:24 -040037@@ -1598,6 +1598,11 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
38 GstOMXAcquireBufferReturn acq_return;
Patrick Williams8b8bc412016-08-17 15:02:23 -050039 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