diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-09-12 16:43:26 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-09-28 14:13:44 +0300 |
commit | d01724a9ab32925140ccda4914682a59b6922ed8 (patch) | |
tree | cc001256a3a14f2b074b32e2723e5cc1739a11c1 /gst | |
parent | dd490e1555047e8b55884608752f1b06c140d53d (diff) |
audiobuffersplit: Drain pending samples if the caps are changing
https://bugzilla.gnome.org/show_bug.cgi?id=787560
Diffstat (limited to 'gst')
-rw-r--r-- | gst/audiobuffersplit/gstaudiobuffersplit.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/gst/audiobuffersplit/gstaudiobuffersplit.c b/gst/audiobuffersplit/gstaudiobuffersplit.c index 6a669f1c1..fd3f8091f 100644 --- a/gst/audiobuffersplit/gstaudiobuffersplit.c +++ b/gst/audiobuffersplit/gstaudiobuffersplit.c @@ -483,14 +483,39 @@ gst_audio_buffer_split_sink_event (GstPad * pad, GstObject * parent, switch (GST_EVENT_TYPE (event)) { case GST_EVENT_CAPS:{ GstCaps *caps; + GstAudioInfo info; gst_event_parse_caps (event, &caps); - ret = gst_audio_info_from_caps (&self->info, caps); - gst_audio_stream_align_set_rate (self->stream_align, self->info.rate); - + ret = gst_audio_info_from_caps (&info, caps); if (ret) { GST_DEBUG_OBJECT (self, "Got caps %" GST_PTR_FORMAT, caps); + + if (!gst_audio_info_is_equal (&info, &self->info)) { + if (self->strict_buffer_size) { + gst_adapter_clear (self->adapter); + } else { + GstAudioFormat format; + gint rate, bpf, samples_per_buffer; + + GST_OBJECT_LOCK (self); + format = + self->info.finfo ? GST_AUDIO_INFO_FORMAT (&self->info) : + GST_AUDIO_FORMAT_UNKNOWN; + rate = GST_AUDIO_INFO_RATE (&self->info); + bpf = GST_AUDIO_INFO_BPF (&self->info); + samples_per_buffer = self->samples_per_buffer; + GST_OBJECT_UNLOCK (self); + + if (format != GST_AUDIO_FORMAT_UNKNOWN && samples_per_buffer != 0) + gst_audio_buffer_split_output (self, TRUE, rate, bpf, + samples_per_buffer); + } + } + self->info = info; + GST_OBJECT_LOCK (self); + gst_audio_stream_align_set_rate (self->stream_align, self->info.rate); + GST_OBJECT_UNLOCK (self); ret = gst_audio_buffer_split_update_samples_per_buffer (self); } else { ret = FALSE; |