omxvideoenc: Always flush the ports and make sure no processing is happening in ::reset

This fixes a race condition that happened when seeking
very often in a short period of time.
This commit is contained in:
Sebastian Dröge 2011-11-10 15:02:22 +01:00
parent e56cff5f2a
commit fbe171ee2c

View file

@ -1123,23 +1123,19 @@ gst_omx_video_enc_reset (GstBaseVideoEncoder * encoder)
g_list_free (GST_BASE_VIDEO_CODEC (self)->frames); g_list_free (GST_BASE_VIDEO_CODEC (self)->frames);
GST_BASE_VIDEO_CODEC (self)->frames = NULL; GST_BASE_VIDEO_CODEC (self)->frames = NULL;
if (self->started) { gst_omx_port_set_flushing (self->in_port, TRUE);
self->started = FALSE; gst_omx_port_set_flushing (self->out_port, TRUE);
gst_omx_port_set_flushing (self->in_port, TRUE); /* Wait until the srcpad loop is finished,
gst_omx_port_set_flushing (self->out_port, TRUE); * unlock GST_BASE_VIDEO_CODEC_STREAM_LOCK to prevent deadlocks
* caused by using this lock from inside the loop function */
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (self);
GST_PAD_STREAM_LOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
GST_PAD_STREAM_UNLOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
GST_BASE_VIDEO_CODEC_STREAM_LOCK (self);
/* Wait until the srcpad loop is finished, gst_omx_port_set_flushing (self->in_port, FALSE);
* unlock GST_BASE_VIDEO_CODEC_STREAM_LOCK to prevent deadlocks gst_omx_port_set_flushing (self->out_port, FALSE);
* caused by using this lock from inside the loop function */
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (self);
GST_PAD_STREAM_LOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
GST_PAD_STREAM_UNLOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
GST_BASE_VIDEO_CODEC_STREAM_LOCK (self);
gst_omx_port_set_flushing (self->in_port, FALSE);
gst_omx_port_set_flushing (self->out_port, FALSE);
}
/* Start the srcpad loop again */ /* Start the srcpad loop again */
self->eos = FALSE; self->eos = FALSE;