From f839a615a0888bd3dca7a81557688fa9c3c1ae56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 17 Sep 2012 13:46:15 +0200 Subject: [PATCH] Fix flushing logic to unbreak handling of flushing seeks --- sys/androidmedia/gstamcaudiodec.c | 3 +-- sys/androidmedia/gstamcvideodec.c | 18 +++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/sys/androidmedia/gstamcaudiodec.c b/sys/androidmedia/gstamcaudiodec.c index f51fbef5e65..0b49935bcd4 100644 --- a/sys/androidmedia/gstamcaudiodec.c +++ b/sys/androidmedia/gstamcaudiodec.c @@ -928,10 +928,8 @@ gst_amc_audio_dec_flush (GstAudioDecoder * decoder, gboolean hard) return; } - gst_amc_audio_dec_drain (self); self->flushing = TRUE; gst_amc_codec_flush (self->codec); - self->flushing = FALSE; /* Wait until the srcpad loop is finished, * unlock GST_AUDIO_DECODER_STREAM_LOCK to prevent deadlocks @@ -940,6 +938,7 @@ gst_amc_audio_dec_flush (GstAudioDecoder * decoder, gboolean hard) GST_PAD_STREAM_LOCK (GST_AUDIO_DECODER_SRC_PAD (self)); GST_PAD_STREAM_UNLOCK (GST_AUDIO_DECODER_SRC_PAD (self)); GST_AUDIO_DECODER_STREAM_LOCK (self); + self->flushing = FALSE; /* Start the srcpad loop again */ self->last_upstream_ts = 0; diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c index 8f58260469a..1185fce05b1 100644 --- a/sys/androidmedia/gstamcvideodec.c +++ b/sys/androidmedia/gstamcvideodec.c @@ -886,7 +886,7 @@ retry: /*} */ if (idx < 0) { - if (self->flushing) + if (self->flushing || self->downstream_flow_ret == GST_FLOW_WRONG_STATE) goto flushing; switch (idx) { @@ -996,7 +996,7 @@ retry: if ((flow_ret = gst_video_decoder_alloc_output_frame (GST_VIDEO_DECODER (self), frame)) != GST_FLOW_OK) { GST_ERROR_OBJECT (self, "Failed to allocate buffer"); - goto failed_allocate; + goto flow_error; } if (!gst_amc_video_dec_fill_buffer (self, idx, &buffer_info, @@ -1124,17 +1124,6 @@ invalid_buffer: GST_VIDEO_DECODER_STREAM_UNLOCK (self); return; } - -failed_allocate: - { - GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL), - ("Failed to allocate output buffer")); - gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self), gst_event_new_eos ()); - gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self)); - self->downstream_flow_ret = GST_FLOW_ERROR; - GST_VIDEO_DECODER_STREAM_UNLOCK (self); - return; - } } static gboolean @@ -1299,10 +1288,8 @@ gst_amc_video_dec_reset (GstVideoDecoder * decoder, gboolean hard) return TRUE; } - gst_amc_video_dec_drain (self); self->flushing = TRUE; gst_amc_codec_flush (self->codec); - self->flushing = FALSE; /* Wait until the srcpad loop is finished, * unlock GST_VIDEO_DECODER_STREAM_LOCK to prevent deadlocks @@ -1311,6 +1298,7 @@ gst_amc_video_dec_reset (GstVideoDecoder * decoder, gboolean hard) GST_PAD_STREAM_LOCK (GST_VIDEO_DECODER_SRC_PAD (self)); GST_PAD_STREAM_UNLOCK (GST_VIDEO_DECODER_SRC_PAD (self)); GST_VIDEO_DECODER_STREAM_LOCK (self); + self->flushing = FALSE; /* Start the srcpad loop again */ self->last_upstream_ts = 0;