[Decoder] Add GObject vmethod implementation for finalize
authorWook Song <wook16.song@samsung.com>
Fri, 15 Mar 2019 09:58:35 +0000 (18:58 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 18 Mar 2019 00:54:15 +0000 (09:54 +0900)
In order to clean up private data of each decoder sub plug-in,
corresponding TensorDecDef.exit() should be invoked by the decoder.
To this end, this patch adds GObject 'finalize' vmethod implementation
to the tensor decoder element.

Signed-off-by: Wook Song <wook16.song@samsung.com>
gst/nnstreamer/tensor_decoder/tensordec.c

index 5ed72ba..d4d4d62 100644 (file)
@@ -139,6 +139,7 @@ static void gst_tensordec_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_tensordec_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
+static void gst_tensordec_class_finalize (GObject * object);
 
 /** GstBaseTransform vmethod implementations */
 static GstFlowReturn gst_tensordec_transform (GstBaseTransform * trans,
@@ -266,6 +267,7 @@ gst_tensordec_class_init (GstTensorDecClass * klass)
 
   gobject_class->set_property = gst_tensordec_set_property;
   gobject_class->get_property = gst_tensordec_get_property;
+  gobject_class->finalize = gst_tensordec_class_finalize;
 
   g_object_class_install_property (gobject_class, PROP_SILENT,
       g_param_spec_boolean ("silent", "Silent", "Produce verbose output",
@@ -543,6 +545,21 @@ gst_tensordec_get_property (GObject * object, guint prop_id,
 }
 
 /**
+ * @brief Finalize instance (GObject vmethod)
+ */
+static void
+gst_tensordec_class_finalize (GObject * object)
+{
+  GstTensorDec *decoder = GST_TENSORDEC (object);
+
+  if (decoder->cleanup_plugin_data) {
+    decoder->cleanup_plugin_data (&decoder->plugin_data);
+  }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
  * @brief Configure tensor metadata from sink caps
  */
 static gboolean