vaapidecode: fix hard reset for seek cases.

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>
This commit is contained in:
XuGuangxin 2013-08-29 14:12:10 +08:00 committed by Gwenole Beauchesne
parent 367944ba32
commit 6e85f08e33

View 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 */