msdkdec: log an error if leaking surfaces in finalize

The for loop in gst_msdkdec_handle_frame is error prone
about how it manages surfaces. Because sometimes it sets
the surface variable to NULL and sometimes it needs to free
it right away. So better to print an error if surfaces are
leaked to help with any change around the loop.
This commit is contained in:
Julien Isorce 2019-11-19 15:35:20 -08:00 committed by Julien Isorce
parent 2077061333
commit 2af672d00a

View file

@ -1569,6 +1569,12 @@ gst_msdkdec_finalize (GObject * object)
g_array_unref (thiz->tasks); g_array_unref (thiz->tasks);
g_object_unref (thiz->adapter); g_object_unref (thiz->adapter);
/* NULL is the empty list. */
if (G_UNLIKELY (thiz->decoded_msdk_surfaces != NULL)) {
GST_ERROR_OBJECT (thiz, "leaking %u surfaces",
g_list_length (thiz->decoded_msdk_surfaces));
}
} }
static gboolean static gboolean
@ -1658,4 +1664,8 @@ gst_msdkdec_init (GstMsdkDec * thiz)
thiz->force_reset_on_res_change = TRUE; thiz->force_reset_on_res_change = TRUE;
thiz->postpone_free_surface = FALSE; thiz->postpone_free_surface = FALSE;
thiz->adapter = gst_adapter_new (); thiz->adapter = gst_adapter_new ();
thiz->input_state = NULL;
thiz->pool = NULL;
thiz->context = NULL;
thiz->decoded_msdk_surfaces = NULL;
} }