vaapidecode: use more standard helpers.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 4 Dec 2012 13:53:15 +0000 (14:53 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 18 Dec 2012 14:31:51 +0000 (15:31 +0100)
Use g_clear_object() [glib >= 2.28] and gst_caps_replace() helper functions
in more places.

gst/vaapi/gstvaapidecode.c

index f8d24e317ace0ff6a4a32a3d3f6fd8505ee6b462..aaa6fc6f00ae73eb3d8dbcb19a0d8bfbac416d4f 100644 (file)
@@ -122,9 +122,7 @@ gst_vaapi_decoder_notify_caps(GObject *obj, GParamSpec *pspec, void *user_data)
 static inline gboolean
 gst_vaapidecode_update_sink_caps(GstVaapiDecode *decode, GstCaps *caps)
 {
-    if (decode->sinkpad_caps)
-        gst_caps_unref(decode->sinkpad_caps);
-    decode->sinkpad_caps = gst_caps_ref(caps);
+    gst_caps_replace(&decode->sinkpad_caps, caps);
     return TRUE;
 }
 
@@ -351,16 +349,8 @@ gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
 static void
 gst_vaapidecode_destroy(GstVaapiDecode *decode)
 {
-    if (decode->decoder) {
-        g_object_unref(decode->decoder);
-        decode->decoder = NULL;
-    }
-
-    if (decode->decoder_caps) {
-        gst_caps_unref(decode->decoder_caps);
-        decode->decoder_caps = NULL;
-    }
-
+    g_clear_object(&decode->decoder);
+    gst_caps_replace(&decode->decoder_caps, NULL);
     gst_vaapidecode_release(decode);
 }
 
@@ -422,23 +412,12 @@ gst_vaapidecode_finalize(GObject *object)
 
     gst_vaapidecode_destroy(decode);
 
-    if (decode->sinkpad_caps) {
-        gst_caps_unref(decode->sinkpad_caps);
-        decode->sinkpad_caps = NULL;
-    }
-
-    if (decode->srcpad_caps) {
-        gst_caps_unref(decode->srcpad_caps);
-        decode->srcpad_caps = NULL;
-    }
+    gst_caps_replace(&decode->sinkpad_caps, NULL);
+    gst_caps_replace(&decode->srcpad_caps,  NULL);
+    gst_caps_replace(&decode->allowed_caps, NULL);
 
     g_clear_object(&decode->display);
 
-    if (decode->allowed_caps) {
-        gst_caps_unref(decode->allowed_caps);
-        decode->allowed_caps = NULL;
-    }
-
     g_cond_clear(&decode->decoder_ready);
     g_mutex_clear(&decode->decoder_mutex);