From 96d82357f2896115863032c96379d4a2942f8339 Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 2 Sep 2015 11:48:29 +0200
Subject: [PATCH] v4l2videodec: use decoder stop command instead of queueing
empty buffers
Only if the decoder stop command fails, keep queueing empty buffers to
signal end of stream as before.
https://bugzilla.gnome.org/show_bug.cgi?id=733864
---
sys/v4l2/gstv4l2videodec.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c
index a21db38..547ccbf 100644
--- a/sys/v4l2/gstv4l2videodec.c
+++ b/sys/v4l2/gstv4l2videodec.c
@@ -336,15 +336,28 @@ gst_v4l2_video_dec_finish (GstVideoDecoder * decoder)
GST_DEBUG_OBJECT (self, "Finishing decoding");
- /* Keep queuing empty buffers until the processing thread has stopped,
- * _pool_process() will return FLUSHING when that happened */
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
- while (ret == GST_FLOW_OK) {
- buffer = gst_buffer_new ();
- ret =
- gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL (self->
- v4l2output->pool), &buffer);
- gst_buffer_unref (buffer);
+
+ if (gst_v4l2_decoder_cmd (self->v4l2output, V4L2_DEC_CMD_STOP, 0)) {
+ GstTask *task = decoder->srcpad->task;
+
+ /* If the decoder stop command succeeded, just wait until processing is
+ * finished */
+ GST_OBJECT_LOCK (task);
+ while (GST_TASK_STATE (task) == GST_TASK_STARTED)
+ GST_TASK_WAIT (task);
+ GST_OBJECT_UNLOCK (task);
+ ret = GST_FLOW_FLUSHING;
+ } else {
+ /* otherwise keep queuing empty buffers until the processing thread has
+ * stopped, _pool_process() will return FLUSHING when that happened */
+ while (ret == GST_FLOW_OK) {
+ buffer = gst_buffer_new ();
+ ret =
+ gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL (self->
+ v4l2output->pool), &buffer);
+ gst_buffer_unref (buffer);
+ }
}
/* and ensure the processing thread has stopped in case another error
--
2.7.4