summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-05-16 20:49:31 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-05-16 20:29:34 +0000
commitab475c22d59eacce1dab01a3dcfa7d9e9c00c8f9 (patch)
tree7b8140fd10211f7a36066b8072dc1d8721dc0e41
parent3b118e2c4501a69a2a5f4f37e1b26bf9d19efad4 (diff)
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>
-rw-r--r--gst-libs/gst/vaapi/gstvaapicontext.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c35
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_x11.c5
-rw-r--r--gst-libs/gst/vaapi/gstvaapiparser_frame.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface.c3
5 files changed, 10 insertions, 37 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index e4839d3e..5d5deb6e 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -255,7 +255,7 @@ context_create (GstVaapiContext * context)
cleanup:
if (surfaces)
- g_array_free (surfaces, TRUE);
+ g_array_unref (surfaces);
return success;
}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 092885a3..5b74d821 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -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)
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
index 50300b87..1f2e1cc6 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
@@ -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)
diff --git a/gst-libs/gst/vaapi/gstvaapiparser_frame.c b/gst-libs/gst/vaapi/gstvaapiparser_frame.c
index 4eda63f9..66da510b 100644
--- a/gst-libs/gst/vaapi/gstvaapiparser_frame.c
+++ b/gst-libs/gst/vaapi/gstvaapiparser_frame.c
@@ -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;
}
}
diff --git a/gst-libs/gst/vaapi/gstvaapisurface.c b/gst-libs/gst/vaapi/gstvaapisurface.c
index 5c821f6b..64ab118e 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface.c
+++ b/gst-libs/gst/vaapi/gstvaapisurface.c
@@ -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);
}
}