omxvideoenc: pause component when flushing
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 28 Aug 2018 11:10:35 +0000 (13:10 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 28 Aug 2018 13:52:14 +0000 (15:52 +0200)
As stated in the spec ("6.1.3 Seek Event Sequence") we should pause
before flushing.
We were pausing the decoder but not the encoder so I just aligned the
two code paths.

https://bugzilla.gnome.org/show_bug.cgi?id=797038

omx/gstomxvideoenc.c

index 9abd9a8..287e003 100644 (file)
@@ -2294,6 +2294,14 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder)
   if (gst_omx_component_get_state (self->enc, 0) == OMX_StateLoaded)
     return TRUE;
 
+  /* 0) Pause the components */
+  if (gst_omx_component_get_state (self->enc, 0) == OMX_StateExecuting) {
+    gst_omx_component_set_state (self->enc, OMX_StatePause);
+    gst_omx_component_get_state (self->enc, GST_CLOCK_TIME_NONE);
+  }
+
+  /* 1) Flush the ports */
+  GST_DEBUG_OBJECT (self, "flushing ports");
   gst_omx_port_set_flushing (self->enc_in_port, 5 * GST_SECOND, TRUE);
   gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, TRUE);
 
@@ -2305,6 +2313,11 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder)
   GST_PAD_STREAM_UNLOCK (GST_VIDEO_ENCODER_SRC_PAD (self));
   GST_VIDEO_ENCODER_STREAM_LOCK (self);
 
+  /* 3) Resume components */
+  gst_omx_component_set_state (self->enc, OMX_StateExecuting);
+  gst_omx_component_get_state (self->enc, GST_CLOCK_TIME_NONE);
+
+  /* 4) Unset flushing to allow ports to accept data again */
   gst_omx_port_set_flushing (self->enc_in_port, 5 * GST_SECOND, FALSE);
   gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, FALSE);
   gst_omx_port_populate (self->enc_out_port);