decodebin3: Convert checks to assertions
authorEdward Hervey <edward@centricular.com>
Wed, 9 Mar 2022 09:15:08 +0000 (10:15 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Fri, 11 Mar 2022 14:02:02 +0000 (15:02 +0100)
"decodebin.input" is never resetted and should always be present, therefore make
it an assertion check

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1900>

subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c

index fd93284..c87ead3 100644 (file)
@@ -844,23 +844,19 @@ gst_decodebin3_input_pad_link (GstPad * pad, GstObject * parent, GstPad * peer)
 {
   GstDecodebin3 *dbin = (GstDecodebin3 *) parent;
   GstPadLinkReturn res = GST_PAD_LINK_OK;
-  DecodebinInput *input;
+  DecodebinInput *input = g_object_get_data (G_OBJECT (pad), "decodebin.input");
+
+  g_return_val_if_fail (input, GST_PAD_LINK_REFUSED);
 
   GST_LOG_OBJECT (parent, "Got link on input pad %" GST_PTR_FORMAT
       ". Creating parsebin if needed", pad);
 
-  if ((input = g_object_get_data (G_OBJECT (pad), "decodebin.input")) == NULL)
-    goto fail;
-
   INPUT_LOCK (dbin);
   if (!ensure_input_parsebin (dbin, input))
     res = GST_PAD_LINK_REFUSED;
   INPUT_UNLOCK (dbin);
 
   return res;
-fail:
-  GST_ERROR_OBJECT (parent, "Failed to retrieve input state from ghost pad");
-  return GST_PAD_LINK_REFUSED;
 }
 
 /* Drop duration query during _input_pad_unlink */
@@ -885,14 +881,13 @@ static void
 gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
 {
   GstDecodebin3 *dbin = (GstDecodebin3 *) parent;
-  DecodebinInput *input;
+  DecodebinInput *input = g_object_get_data (G_OBJECT (pad), "decodebin.input");
+
+  g_return_if_fail (input);
 
   GST_LOG_OBJECT (parent, "Got unlink on input pad %" GST_PTR_FORMAT
       ". Removing parsebin.", pad);
 
-  if ((input = g_object_get_data (G_OBJECT (pad), "decodebin.input")) == NULL)
-    goto fail;
-
   INPUT_LOCK (dbin);
   if (input->parsebin == NULL) {
     INPUT_UNLOCK (dbin);
@@ -952,10 +947,6 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
   }
   INPUT_UNLOCK (dbin);
   return;
-
-fail:
-  GST_ERROR_OBJECT (parent, "Failed to retrieve input state from ghost pad");
-  return;
 }
 
 static void