From 2af672d00a759c4f0309d2625c920f02c51c2ca2 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Tue, 19 Nov 2019 15:35:20 -0800 Subject: [PATCH] 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. --- sys/msdk/gstmsdkdec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index 74d590df06..54fbda9edc 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -1569,6 +1569,12 @@ gst_msdkdec_finalize (GObject * object) g_array_unref (thiz->tasks); 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 @@ -1658,4 +1664,8 @@ gst_msdkdec_init (GstMsdkDec * thiz) thiz->force_reset_on_res_change = TRUE; thiz->postpone_free_surface = FALSE; thiz->adapter = gst_adapter_new (); + thiz->input_state = NULL; + thiz->pool = NULL; + thiz->context = NULL; + thiz->decoded_msdk_surfaces = NULL; }