diff --git a/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiodecoder.c b/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiodecoder.c index acb6314ea0..14a603e77d 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiodecoder.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiodecoder.c @@ -1423,9 +1423,23 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec, frames = priv->frames.length; } - if (G_LIKELY (priv->frames.length)) + if (G_LIKELY (buf)) + buf = gst_buffer_make_writable (buf); + + if (G_LIKELY (priv->frames.length)) { ts = GST_BUFFER_PTS (priv->frames.head->data); - else + if (G_LIKELY (buf)) { + /* propagate RESYNC flag to output buffer */ + if (GST_BUFFER_FLAG_IS_SET (priv->frames.head->data, + GST_BUFFER_FLAG_RESYNC)) + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_RESYNC); + if (is_subframe) { + priv->frames.head->data = + gst_buffer_make_writable (priv->frames.head->data); + GST_BUFFER_FLAG_UNSET (priv->frames.head->data, GST_BUFFER_FLAG_RESYNC); + } + } + } else ts = GST_CLOCK_TIME_NONE; GST_DEBUG_OBJECT (dec, "leading frame ts %" GST_TIME_FORMAT, @@ -1477,7 +1491,8 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec, * discard buffer ts and carry on producing perfect stream, * otherwise resync to ts */ if (G_UNLIKELY (diff < (gint64) - dec->priv->tolerance || - diff > (gint64) dec->priv->tolerance)) { + diff > (gint64) dec->priv->tolerance || + GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_RESYNC))) { GST_DEBUG_OBJECT (dec, "base_ts resync"); priv->base_ts = ts; priv->samples = 0; @@ -1501,7 +1516,6 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec, priv->taglist_changed = FALSE; } - buf = gst_buffer_make_writable (buf); if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) { GST_BUFFER_PTS (buf) = priv->base_ts +