vaapidecode: fix hard reset for seek cases.
authorXuGuangxin <guangxin.xu@intel.com>
Thu, 29 Aug 2013 06:12:10 +0000 (14:12 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 21 Nov 2013 10:08:23 +0000 (11:08 +0100)
Fix hard reset for seek cases by flushing the GstVaapiDecoder queue
and completely purge any decoded output frame that may come out from
it. At this stage, the GstVaapiDecoder shall be in a complete clean
state to start decoding over new buffers.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst/vaapi/gstvaapidecode.c

index d2c149f..4f99170 100644 (file)
@@ -639,6 +639,21 @@ gst_vaapidecode_reset_full(GstVaapiDecode *decode, GstCaps *caps, gboolean hard)
 
     /* Reset timers if hard reset was requested (e.g. seek) */
     if (hard) {
+        GstVideoDecoder * const vdec = GST_VIDEO_DECODER(decode);
+        GstVideoCodecFrame *out_frame = NULL;
+
+        gst_vaapi_decoder_flush(decode->decoder);
+        GST_VIDEO_DECODER_STREAM_UNLOCK(vdec);
+        gst_pad_stop_task(decode->srcpad);
+        GST_VIDEO_DECODER_STREAM_LOCK(vdec);
+        decode->decoder_loop_status = GST_FLOW_OK;
+
+        /* Purge all decoded frames as we don't need them (e.g. seek) */
+        while (gst_vaapi_decoder_get_frame_with_timeout(decode->decoder,
+                   &out_frame, 0) == GST_VAAPI_DECODER_STATUS_SUCCESS) {
+            gst_video_codec_frame_unref(out_frame);
+            out_frame = NULL;
+        }
     }
 
     /* Only reset decoder if codec type changed */