vaapidecode: Tell the base class about released frames on close

The base class needs to be informed about frames that were still queued
in the decoder on release, otherwise they are leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=747999
This commit is contained in:
Olivier Crete 2015-04-16 12:53:18 -04:00 committed by Víctor Manuel Jáquez Leal
parent dedbbdd41b
commit 11c963a3c1
2 changed files with 16 additions and 19 deletions

View file

@ -774,6 +774,7 @@ decode_sequence_end(GstVaapiDecoderMpeg2 *decoder)
{ {
GstVaapiDecoderMpeg2Private * const priv = &decoder->priv; GstVaapiDecoderMpeg2Private * const priv = &decoder->priv;
if (priv->dpb)
gst_vaapi_dpb_flush(priv->dpb); gst_vaapi_dpb_flush(priv->dpb);
return GST_VAAPI_DECODER_STATUS_SUCCESS; return GST_VAAPI_DECODER_STATUS_SUCCESS;
} }

View file

@ -633,6 +633,19 @@ gst_vaapidecode_create (GstVaapiDecode * decode, GstCaps * caps)
static void static void
gst_vaapidecode_destroy (GstVaapiDecode * decode) gst_vaapidecode_destroy (GstVaapiDecode * decode)
{ {
GstVideoCodecFrame *out_frame = NULL;
if (decode->decoder) {
gst_vaapi_decoder_flush (decode->decoder);
/* 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_decoder_release_frame (GST_VIDEO_DECODER (decode), out_frame);
gst_video_codec_frame_unref (out_frame);
out_frame = NULL;
}
}
gst_vaapi_decoder_replace (&decode->decoder, NULL); gst_vaapi_decoder_replace (&decode->decoder, NULL);
gst_caps_replace (&decode->decoder_caps, NULL); gst_caps_replace (&decode->decoder_caps, NULL);
@ -652,24 +665,7 @@ gst_vaapidecode_reset_full (GstVaapiDecode * decode, GstCaps * caps,
/* Reset tracked frame size */ /* Reset tracked frame size */
decode->current_frame_size = 0; decode->current_frame_size = 0;
/* Reset timers if hard reset was requested (e.g. seek) */ if (!hard && decode->decoder && decode->decoder_caps) {
if (hard) {
GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode);
GstVideoCodecFrame *out_frame = NULL;
gst_vaapi_decoder_flush (decode->decoder);
/* 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_decoder_drop_frame (vdec, out_frame);
gst_video_codec_frame_unref (out_frame);
out_frame = NULL;
}
}
/* Only reset decoder if codec type changed */
else if (decode->decoder && decode->decoder_caps) {
if (gst_caps_is_always_compatible (caps, decode->decoder_caps)) if (gst_caps_is_always_compatible (caps, decode->decoder_caps))
return TRUE; return TRUE;
codec = gst_vaapi_codec_from_caps (caps); codec = gst_vaapi_codec_from_caps (caps);