From 90da3c665e36b5889e8053213c93c268d8ca5430 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 25 Jul 2017 14:27:45 +0200 Subject: [PATCH] omxvideoenc: start src thread in handle_frame() Makes the code simpler as we no longer need to restart the thread in gst_omx_video_enc_flush() and It's more symetric which the omxvideodec implementation. I'm also going to move the enabling of the OMX component in handle_frame() and the src pad thread needs to be started after it. https://bugzilla.gnome.org/show_bug.cgi?id=785967 --- omx/gstomxvideoenc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index cae4e421cc..10ae3b5f66 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -395,6 +395,8 @@ gst_omx_video_enc_close (GstVideoEncoder * encoder) gst_omx_component_free (self->enc); self->enc = NULL; + self->started = FALSE; + return TRUE; } @@ -1284,12 +1286,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, if (!gst_omx_video_enc_enable (self)) return FALSE; - /* Start the srcpad loop again */ - GST_DEBUG_OBJECT (self, "Starting task again"); self->downstream_flow_ret = GST_FLOW_OK; - gst_pad_start_task (GST_VIDEO_ENCODER_SRC_PAD (self), - (GstTaskFunction) gst_omx_video_enc_loop, self, NULL); - return TRUE; } @@ -1323,8 +1320,8 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder) /* Start the srcpad loop again */ self->last_upstream_ts = 0; self->downstream_flow_ret = GST_FLOW_OK; - gst_pad_start_task (GST_VIDEO_ENCODER_SRC_PAD (self), - (GstTaskFunction) gst_omx_video_enc_loop, encoder, NULL); + self->started = FALSE; + GST_DEBUG_OBJECT (self, "Flush finished"); return TRUE; } @@ -1521,6 +1518,12 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder, return self->downstream_flow_ret; } + if (!self->started) { + GST_DEBUG_OBJECT (self, "Starting task"); + gst_pad_start_task (GST_VIDEO_ENCODER_SRC_PAD (self), + (GstTaskFunction) gst_omx_video_enc_loop, self, NULL); + } + port = self->enc_in_port; while (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {