[PATCH 2/3] vpu/encoder_base: add a 'close' subclass vfunc

phdm at macq.eu phdm at macq.eu
Tue Sep 6 12:53:01 UTC 2016


From: Philippe De Muyter <phdm at macqel.be>

Signed-off-by: Philippe De Muyter <phdm at macqel.be>
---
 src/vpu/encoder_base.c | 8 ++++++++
 src/vpu/encoder_base.h | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/src/vpu/encoder_base.c b/src/vpu/encoder_base.c
index 458aec1..fe020d1 100644
--- a/src/vpu/encoder_base.c
+++ b/src/vpu/encoder_base.c
@@ -316,6 +316,14 @@ static gboolean gst_imx_vpu_encoder_base_start(GstVideoEncoder *encoder)
 static gboolean gst_imx_vpu_encoder_base_stop(GstVideoEncoder *encoder)
 {
 	GstImxVpuEncoderBase *vpu_encoder_base = GST_IMX_VPU_ENCODER_BASE(encoder);
+	GstImxVpuEncoderBaseClass *klass;
+
+	klass = GST_IMX_VPU_ENCODER_BASE_CLASS(G_OBJECT_GET_CLASS(vpu_encoder_base));
+	/* Let the derived class terminate cleanly */
+	if ((klass->close != NULL) && !klass->close(vpu_encoder_base))
+	{
+		GST_ERROR_OBJECT(vpu_encoder_base, "derived class could not terminate cleanly");
+	}
 
 	gst_imx_vpu_encoder_base_close(vpu_encoder_base);
 
diff --git a/src/vpu/encoder_base.h b/src/vpu/encoder_base.h
index 73a42f7..19bc15f 100644
--- a/src/vpu/encoder_base.h
+++ b/src/vpu/encoder_base.h
@@ -130,6 +130,9 @@ struct _GstImxVpuEncoderBase
  *                         *output_buffer must point to this new buffer, and the previous
  *                         *output_buffer must be unref'd.
  *                         Returns TRUE if the call succeeded, and FALSE otherwise.
+ * @close:		   Optional.
+ *                         Free all the private allocations done by the subclass
+ *                         Returns TRUE if the call succeeded, and FALSE otherwise.
  */
 struct _GstImxVpuEncoderBaseClass
 {
@@ -141,6 +144,7 @@ struct _GstImxVpuEncoderBaseClass
 	GstCaps* (*get_output_caps)(GstImxVpuEncoderBase *vpu_encoder_base);
 	gboolean (*set_frame_enc_params)(GstImxVpuEncoderBase *vpu_encoder_base, ImxVpuEncParams *enc_params);
 	gboolean (*process_output_buffer)(GstImxVpuEncoderBase *vpu_encoder_base, GstVideoCodecFrame *frame, GstBuffer **output_buffer);
+	gboolean (*close)(GstImxVpuEncoderBase *vpu_encoder_base);
 };
 
 
-- 
1.8.4.5



More information about the gstreamer-devel mailing list