decode->srcpad_caps = NULL;
}
- if (decode->display) {
- g_object_unref(decode->display);
- decode->display = NULL;
- }
+ g_clear_object(&decode->display);
if (decode->allowed_caps) {
gst_caps_unref(decode->allowed_caps);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_vaapidecode_destroy(decode);
- if (decode->display) {
- g_object_unref(decode->display);
- decode->display = NULL;
- }
+ g_clear_object(&decode->display);
decode->is_ready = FALSE;
break;
default:
download->allowed_caps = NULL;
}
- if (download->images) {
- g_object_unref(download->images);
- download->images = NULL;
- }
-
- if (download->display) {
- g_object_unref(download->display);
- download->display = NULL;
- }
+ g_clear_object(&download->images);
+ g_clear_object(&download->display);
}
static void
{
GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
- if (download->display) {
- g_object_unref(download->display);
- download->display = NULL;
- }
+ g_clear_object(&download->display);
+
return TRUE;
}
download->image_format = format;
download->image_width = width;
download->image_height = height;
- if (download->images)
- g_object_unref(download->images);
+ g_clear_object(&download->images);
download->images = gst_vaapi_image_pool_new(download->display, caps);
if (!download->images)
return FALSE;
{
gst_caps_replace(&postproc->postproc_caps, NULL);
- if (postproc->display) {
- g_object_unref(postproc->display);
- postproc->display = NULL;
- }
+ g_clear_object(&postproc->display);
}
static gboolean
static void
gst_vaapisink_destroy(GstVaapiSink *sink)
{
- if (sink->texture) {
- g_object_unref(sink->texture);
- sink->texture = NULL;
- }
-
- if (sink->display) {
- g_object_unref(sink->display);
- sink->display = NULL;
- }
+ g_clear_object(&sink->texture);
+ g_clear_object(&sink->display);
gst_caps_replace(&sink->caps, NULL);
}
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window)) == xid)
return TRUE;
- if (sink->window) {
- g_object_unref(sink->window);
- sink->window = NULL;
- }
+ g_clear_object(&sink->window);
#if USE_VAAPISINK_GLX
if (sink->use_glx)
{
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
- if (sink->window) {
- g_object_unref(sink->window);
- sink->window = NULL;
- }
+ g_clear_object(&sink->window);
+ g_clear_object(&sink->display);
- if (sink->display) {
- g_object_unref(sink->display);
- sink->display = NULL;
- }
return TRUE;
}
gst_video_buffer_get_overlay_composition(buffer);
if (sink->display != gst_vaapi_video_buffer_get_display (vbuffer)) {
- if (sink->display)
- g_object_unref (sink->display);
+ g_clear_object(&sink->display);
sink->display = g_object_ref (gst_vaapi_video_buffer_get_display (vbuffer));
}
static void
gst_vaapiupload_destroy(GstVaapiUpload *upload)
{
- if (upload->images) {
- g_object_unref(upload->images);
- upload->images = NULL;
- }
-
- if (upload->surfaces) {
- g_object_unref(upload->surfaces);
- upload->surfaces = NULL;
- }
-
- if (upload->display) {
- g_object_unref(upload->display);
- upload->display = NULL;
- }
+ g_clear_object(&upload->images);
+ g_clear_object(&upload->surfaces);
+ g_clear_object(&upload->display);
}
static void
{
GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
- if (upload->display) {
- g_object_unref(upload->display);
- upload->display = NULL;
- }
+ g_clear_object(&upload->display);
+
return TRUE;
}
if (width != upload->image_width || height != upload->image_height) {
upload->image_width = width;
upload->image_height = height;
- if (upload->images)
- g_object_unref(upload->images);
+ g_clear_object(&upload->images);
upload->images = gst_vaapi_image_pool_new(upload->display, caps);
if (!upload->images)
return FALSE;
if (width != upload->surface_width || height != upload->surface_height) {
upload->surface_width = width;
upload->surface_height = height;
- if (upload->surfaces)
- g_object_unref(upload->surfaces);
+ g_clear_object(&upload->surfaces);
upload->surfaces = gst_vaapi_surface_pool_new(upload->display, caps);
if (!upload->surfaces)
return FALSE;