va: Fix some gst_object_unref error because the pointer is NULL.

!1957 introduces some error of gst_object_unref for NULL pointer.
Fixes all of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1959>
This commit is contained in:
He Junyan 2021-01-17 01:16:17 +08:00
parent 82c0f90197
commit 0158849145
2 changed files with 11 additions and 9 deletions

View file

@ -51,7 +51,7 @@ gst_va_base_dec_open (GstVideoDecoder * decoder)
gst_object_replace ((GstObject **) (&base->decoder), gst_object_replace ((GstObject **) (&base->decoder),
(GstObject *) va_decoder); (GstObject *) va_decoder);
gst_object_unref (va_decoder); gst_clear_object (&va_decoder);
} else { } else {
ret = TRUE; ret = TRUE;
} }
@ -98,10 +98,10 @@ gst_va_base_dec_getcaps (GstVideoDecoder * decoder, GstCaps * filter)
gst_object_replace ((GstObject **) & va_decoder, (GstObject *) base->decoder); gst_object_replace ((GstObject **) & va_decoder, (GstObject *) base->decoder);
if (va_decoder) if (va_decoder) {
caps = gst_va_decoder_get_sinkpad_caps (va_decoder); caps = gst_va_decoder_get_sinkpad_caps (va_decoder);
gst_object_unref (va_decoder);
gst_object_unref (va_decoder); }
if (caps) { if (caps) {
if (filter) { if (filter) {
@ -133,7 +133,7 @@ gst_va_base_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
ret = gst_va_handle_context_query (GST_ELEMENT_CAST (decoder), query, ret = gst_va_handle_context_query (GST_ELEMENT_CAST (decoder), query,
display); display);
gst_object_unref (display); gst_clear_object (&display);
break; break;
} }
case GST_QUERY_CAPS:{ case GST_QUERY_CAPS:{
@ -151,7 +151,7 @@ gst_va_base_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
if (!fixed_caps && va_decoder) if (!fixed_caps && va_decoder)
caps = gst_va_decoder_get_srcpad_caps (va_decoder); caps = gst_va_decoder_get_srcpad_caps (va_decoder);
gst_object_unref (va_decoder); gst_clear_object (&va_decoder);
if (caps) { if (caps) {
if (filter) { if (filter) {
@ -191,7 +191,8 @@ gst_va_base_dec_sink_query (GstVideoDecoder * decoder, GstQuery * query)
ret = gst_va_handle_context_query (GST_ELEMENT_CAST (decoder), query, ret = gst_va_handle_context_query (GST_ELEMENT_CAST (decoder), query,
display); display);
gst_object_unref (display); gst_clear_object (&display);
return ret; return ret;
} }

View file

@ -199,12 +199,13 @@ gst_va_ensure_element_data (gpointer element, const gchar * render_device_path,
display = gst_va_display_drm_new_from_path (render_device_path); display = gst_va_display_drm_new_from_path (render_device_path);
gst_object_replace ((GstObject **) display_ptr, (GstObject *) display); gst_object_replace ((GstObject **) display_ptr, (GstObject *) display);
gst_object_unref (display);
gst_va_element_propagate_display_context (element, display); gst_va_element_propagate_display_context (element, display);
gst_clear_object (&display);
done: done:
return *display_ptr != NULL; return g_atomic_pointer_get (display_ptr) != NULL;
} }
gboolean gboolean