Commit c0d778c2 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜 Committed by Haihao Xiang

msdk: Use gst_clear_object()

`gst_object_replace()` is not supposed to be used for unreffing and
NULLing objects.
parent bda68734
......@@ -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)) {
......
......@@ -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);
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment