summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-01-17 13:45:35 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-01-17 22:17:06 +0530
commitf14d5a17c43cfd912ccb118b2560ee267004de4e (patch)
treebe0c5a2c815f913d57a5742ff02a271020717029
parent39fe8289653ae9a84724dbd79777d363d56c68fa (diff)
downloadgstreamer-plugins-bad-f14d5a17c43cfd912ccb118b2560ee267004de4e.tar.gz
msdk: Use gst_clear_object()
`gst_object_replace()` is not supposed to be used for unreffing and NULLing objects.
-rw-r--r--sys/msdk/gstmsdkdec.c11
-rw-r--r--sys/msdk/gstmsdkenc.c10
-rw-r--r--sys/msdk/gstmsdkvpp.c14
3 files changed, 15 insertions, 20 deletions
diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c
index f50561789..739233a38 100644
--- a/sys/msdk/gstmsdkdec.c
+++ b/sys/msdk/gstmsdkdec.c
@@ -692,8 +692,7 @@ gst_msdkdec_close (GstVideoDecoder * decoder)
{
GstMsdkDec *thiz = GST_MSDKDEC (decoder);
- if (thiz->context)
- gst_object_replace ((GstObject **) & thiz->context, NULL);
+ gst_clear_object (&thiz->context);
return TRUE;
}
@@ -1232,8 +1231,7 @@ gst_msdkdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
/* Decoder always use its own pool. So we create a pool if msdk apis
* previously requested for allocation (do_realloc = TRUE) */
if (thiz->do_realloc || !thiz->pool) {
- if (thiz->pool)
- gst_object_replace ((GstObject **) & thiz->pool, NULL);
+ gst_clear_object (&thiz->pool);
GST_INFO_OBJECT (decoder, "create new MSDK bufferpool");
thiz->pool =
gst_msdkdec_create_buffer_pool (thiz, &thiz->output_info, min_buffers);
@@ -1457,7 +1455,10 @@ gst_msdkdec_finalize (GObject * object)
GstMsdkDec *thiz = GST_MSDKDEC (object);
g_array_unref (thiz->tasks);
- g_object_unref (thiz->adapter);
+ thiz->tasks = NULL;
+ g_clear_object (&thiz->adapter);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c
index d05e168cd..4d36d1631 100644
--- a/sys/msdk/gstmsdkenc.c
+++ b/sys/msdk/gstmsdkenc.c
@@ -540,8 +540,8 @@ gst_msdkenc_close_encoder (GstMsdkEnc * thiz)
GST_DEBUG_OBJECT (thiz, "Closing encoder with context %" GST_PTR_FORMAT,
thiz->context);
- gst_object_replace ((GstObject **) & thiz->msdk_pool, NULL);
- gst_object_replace ((GstObject **) & thiz->msdk_converted_pool, NULL);
+ gst_clear_object (&thiz->msdk_pool);
+ gst_clear_object (&thiz->msdk_converted_pool);
if (thiz->use_video_memory)
gst_msdk_frame_free (thiz->context, &thiz->alloc_resp);
@@ -1452,7 +1452,7 @@ gst_msdkenc_stop (GstVideoEncoder * encoder)
gst_video_codec_state_unref (thiz->input_state);
thiz->input_state = NULL;
- gst_object_replace ((GstObject **) & thiz->context, NULL);
+ gst_clear_object (&thiz->context);
return TRUE;
}
@@ -1548,8 +1548,8 @@ gst_msdkenc_finalize (GObject * object)
gst_video_codec_state_unref (thiz->input_state);
thiz->input_state = NULL;
- gst_object_replace ((GstObject **) & thiz->msdk_pool, NULL);
- gst_object_replace ((GstObject **) & thiz->msdk_converted_pool, NULL);
+ gst_clear_object (&thiz->msdk_pool);
+ gst_clear_object (&thiz->msdk_converted_pool);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/sys/msdk/gstmsdkvpp.c b/sys/msdk/gstmsdkvpp.c
index d0e0a4659..ca107d1a7 100644
--- a/sys/msdk/gstmsdkvpp.c
+++ b/sys/msdk/gstmsdkvpp.c
@@ -781,17 +781,12 @@ gst_msdkvpp_close (GstMsdkVPP * thiz)
msdk_status_to_string (status));
}
- if (thiz->context)
- gst_object_replace ((GstObject **) & thiz->context, NULL);
+ gst_clear_object (&thiz->context);
memset (&thiz->param, 0, sizeof (thiz->param));
- if (thiz->sinkpad_buffer_pool)
- gst_object_unref (thiz->sinkpad_buffer_pool);
- thiz->sinkpad_buffer_pool = NULL;
- if (thiz->srcpad_buffer_pool)
- gst_object_unref (thiz->srcpad_buffer_pool);
- thiz->srcpad_buffer_pool = NULL;
+ gst_clear_object (&thiz->sinkpad_buffer_pool);
+ gst_clear_object (&thiz->srcpad_buffer_pool);
thiz->buffer_duration = GST_CLOCK_TIME_NONE;
gst_video_info_init (&thiz->sinkpad_info);
@@ -1031,8 +1026,7 @@ gst_msdkvpp_initialize (GstMsdkVPP * thiz)
no_vpp:
GST_OBJECT_UNLOCK (thiz);
- if (thiz->context)
- gst_object_replace ((GstObject **) & thiz->context, NULL);
+ gst_clear_object (&thiz->context);
return FALSE;
}