flacdec: flush flac decoder on lost sync.
This to allow the decoder to start searching for a new frame again. https://bugzilla.gnome.org/show_bug.cgi?id=791473
This commit is contained in:
parent
d90b6ec459
commit
34abfbff18
@ -178,6 +178,7 @@ gst_flac_dec_class_init (GstFlacDecClass * klass)
|
|||||||
static void
|
static void
|
||||||
gst_flac_dec_init (GstFlacDec * flacdec)
|
gst_flac_dec_init (GstFlacDec * flacdec)
|
||||||
{
|
{
|
||||||
|
flacdec->do_resync = FALSE;
|
||||||
gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (flacdec), TRUE);
|
gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (flacdec), TRUE);
|
||||||
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST
|
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST
|
||||||
(flacdec), TRUE);
|
(flacdec), TRUE);
|
||||||
@ -511,7 +512,7 @@ gst_flac_dec_error_cb (const FLAC__StreamDecoder * d,
|
|||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
|
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
|
||||||
/* Ignore this error and keep processing */
|
dec->do_resync = TRUE;
|
||||||
return;
|
return;
|
||||||
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
|
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
|
||||||
error = "bad header";
|
error = "bad header";
|
||||||
@ -741,6 +742,7 @@ gst_flac_dec_flush (GstAudioDecoder * audio_dec, gboolean hard)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dec->do_resync = FALSE;
|
||||||
FLAC__stream_decoder_flush (dec->decoder);
|
FLAC__stream_decoder_flush (dec->decoder);
|
||||||
gst_adapter_clear (dec->adapter);
|
gst_adapter_clear (dec->adapter);
|
||||||
}
|
}
|
||||||
@ -758,6 +760,12 @@ gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf)
|
|||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dec->do_resync) {
|
||||||
|
GST_WARNING_OBJECT (dec, "Lost sync, flushing decoder");
|
||||||
|
FLAC__stream_decoder_flush (dec->decoder);
|
||||||
|
dec->do_resync = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec, "frame: ts %" GST_TIME_FORMAT ", flags 0x%04x, "
|
GST_LOG_OBJECT (dec, "frame: ts %" GST_TIME_FORMAT ", flags 0x%04x, "
|
||||||
"%" G_GSIZE_FORMAT " bytes", GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
"%" G_GSIZE_FORMAT " bytes", GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
||||||
GST_BUFFER_FLAGS (buf), gst_buffer_get_size (buf));
|
GST_BUFFER_FLAGS (buf), gst_buffer_get_size (buf));
|
||||||
|
@ -59,6 +59,7 @@ struct _GstFlacDec {
|
|||||||
guint16 min_blocksize;
|
guint16 min_blocksize;
|
||||||
guint16 max_blocksize;
|
guint16 max_blocksize;
|
||||||
|
|
||||||
|
gboolean do_resync;
|
||||||
gint error_count;
|
gint error_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user