libs: use array_unref() rather than array_free()

It is more convinience and thread-safe.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/325>
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-05-16 20:49:31 +02:00
parent 3b118e2c45
commit ab475c22d5
5 changed files with 10 additions and 37 deletions

View file

@ -255,7 +255,7 @@ context_create (GstVaapiContext * context)
cleanup:
if (surfaces)
g_array_free (surfaces, TRUE);
g_array_unref (surfaces);
return success;
}

View file

@ -898,35 +898,12 @@ gst_vaapi_display_destroy (GstVaapiDisplay * display)
{
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
if (priv->decoders) {
g_ptr_array_free (priv->decoders, TRUE);
priv->decoders = NULL;
}
if (priv->encoders) {
g_ptr_array_free (priv->encoders, TRUE);
priv->encoders = NULL;
}
if (priv->codecs) {
g_array_free (priv->codecs, TRUE);
priv->codecs = NULL;
}
if (priv->image_formats) {
g_array_free (priv->image_formats, TRUE);
priv->image_formats = NULL;
}
if (priv->subpicture_formats) {
g_array_free (priv->subpicture_formats, TRUE);
priv->subpicture_formats = NULL;
}
if (priv->properties) {
g_array_free (priv->properties, TRUE);
priv->properties = NULL;
}
g_clear_pointer (&priv->decoders, g_ptr_array_unref);
g_clear_pointer (&priv->encoders, g_ptr_array_unref);
g_clear_pointer (&priv->codecs, g_array_unref);
g_clear_pointer (&priv->image_formats, g_array_unref);
g_clear_pointer (&priv->subpicture_formats, g_array_unref);
g_clear_pointer (&priv->properties, g_array_unref);
if (priv->display) {
if (!priv->parent)

View file

@ -156,10 +156,7 @@ gst_vaapi_display_x11_close_display (GstVaapiDisplay * display)
GstVaapiDisplayX11Private *const priv =
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
if (priv->pixmap_formats) {
g_array_free (priv->pixmap_formats, TRUE);
priv->pixmap_formats = NULL;
}
g_clear_pointer (&priv->pixmap_formats, g_array_unref);
if (priv->x11_display) {
if (!priv->use_foreign_display)

View file

@ -60,7 +60,7 @@ free_units (GArray ** units_ptr)
&g_array_index (units, GstVaapiDecoderUnit, i);
gst_vaapi_decoder_unit_clear (unit);
}
g_array_free (units, TRUE);
g_array_unref (units);
*units_ptr = NULL;
}
}

View file

@ -61,8 +61,7 @@ gst_vaapi_surface_destroy_subpictures (GstVaapiSurface * surface)
{
if (surface->subpictures) {
g_ptr_array_foreach (surface->subpictures, destroy_subpicture_cb, surface);
g_ptr_array_free (surface->subpictures, TRUE);
surface->subpictures = NULL;
g_clear_pointer (&surface->subpictures, g_ptr_array_unref);
}
}