From 8227310d223119a28151baca492b995a74d9aa5b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 12 Mar 2015 01:56:44 +0530 Subject: [PATCH] audiomixer: Mark a discont when we receive a new segment event This allows us to handle new segment events correctly; either by dropping buffers or inserting silence; for example if the offset is changed on an srcpad connected to audiomixer. --- gst/audiomixer/gstaudiomixer.c | 9 ++++++++- gst/audiomixer/gstaudiomixer.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gst/audiomixer/gstaudiomixer.c b/gst/audiomixer/gstaudiomixer.c index 8881d63ebb..2165ab70e1 100644 --- a/gst/audiomixer/gstaudiomixer.c +++ b/gst/audiomixer/gstaudiomixer.c @@ -675,7 +675,9 @@ gst_audiomixer_sink_event (GstAggregator * agg, GstAggregatorPad * aggpad, } case GST_EVENT_SEGMENT: { + GstAudioMixerPad *pad = GST_AUDIO_MIXER_PAD (aggpad); const GstSegment *segment; + gst_event_parse_segment (event, &segment); if (segment->rate != agg->segment.rate) { GST_ERROR_OBJECT (aggpad, @@ -689,6 +691,10 @@ gst_audiomixer_sink_event (GstAggregator * agg, GstAggregatorPad * aggpad, res = FALSE; gst_event_unref (event); event = NULL; + } else { + /* Ideally, this should only be set when the new segment causes running + * times to change, and hence needs discont calculation in fill_buffer */ + pad->new_segment = TRUE; } break; } @@ -1007,8 +1013,9 @@ gst_audio_mixer_fill_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad, if (GST_BUFFER_IS_DISCONT (inbuf) || GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_RESYNC) - || pad->next_offset == -1) { + || pad->new_segment || pad->next_offset == -1) { discont = TRUE; + pad->new_segment = FALSE; } else { guint64 diff, max_sample_diff; diff --git a/gst/audiomixer/gstaudiomixer.h b/gst/audiomixer/gstaudiomixer.h index 9e14582951..9507e6c5d8 100644 --- a/gst/audiomixer/gstaudiomixer.h +++ b/gst/audiomixer/gstaudiomixer.h @@ -110,6 +110,9 @@ struct _GstAudioMixerPad { /* Last time we noticed a discont */ GstClockTime discont_time; + + /* A new unhandled segment event has been received */ + gboolean new_segment; }; struct _GstAudioMixerPadClass {