summaryrefslogtreecommitdiff
path: root/sys/msdk
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-01-17 13:45:35 +0530
committerHaihao Xiang <haihao.xiang@intel.com>2020-01-21 00:38:41 +0000
commitc0d778c2c7a5075f8a26145f9fa3cabd1e6a78e3 (patch)
treec10050c43335b4d7e337fba38a3484133a323234 /sys/msdk
parentbda687344b11ed56dbbf6186a0a02b64ecf08bcd (diff)
msdk: Use gst_clear_object()
`gst_object_replace()` is not supposed to be used for unreffing and NULLing objects.
Diffstat (limited to 'sys/msdk')
-rw-r--r--sys/msdk/gstmsdkdec.c9
-rw-r--r--sys/msdk/gstmsdkenc.c12
-rw-r--r--sys/msdk/gstmsdkvpp.c14
3 files changed, 14 insertions, 21 deletions
diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c
index 5296ad552..6efa1a83f 100644
--- a/sys/msdk/gstmsdkdec.c
+++ b/sys/msdk/gstmsdkdec.c
@@ -761,8 +761,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;
}
@@ -1375,8 +1374,7 @@ gst_msdkdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
if (thiz->do_realloc || !thiz->pool) {
GstVideoCodecState *output_state =
gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz));
- 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, &output_state->info, min_buffers);
@@ -1612,7 +1610,8 @@ 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);
/* NULL is the empty list. */
if (G_UNLIKELY (thiz->decoded_msdk_surfaces != NULL)) {
diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c
index 8570285e2..943ae1d25 100644
--- a/sys/msdk/gstmsdkenc.c
+++ b/sys/msdk/gstmsdkenc.c
@@ -700,8 +700,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);
@@ -1295,7 +1295,7 @@ gst_msdkenc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state)
goto done;
}
/* Release current pool because we are going to create a new one */
- gst_object_replace ((GstObject **) & thiz->msdk_converted_pool, NULL);
+ gst_clear_object (&thiz->msdk_converted_pool);
}
/* Otherwise create a new pool */
@@ -1662,7 +1662,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;
}
@@ -1760,8 +1760,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 23c2dbcba..b39d133f6 100644
--- a/sys/msdk/gstmsdkvpp.c
+++ b/sys/msdk/gstmsdkvpp.c
@@ -850,17 +850,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);
@@ -1105,8 +1100,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;
}