From c29e04674a2b5fffd9c29e9e6950693345030ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 15 Jan 2014 23:30:28 +0100 Subject: [PATCH] audiomixer: Fix and simplify overlap calculation --- gst/audiomixer/gstaudiomixer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/audiomixer/gstaudiomixer.c b/gst/audiomixer/gstaudiomixer.c index 2605cc3705..5929851064 100644 --- a/gst/audiomixer/gstaudiomixer.c +++ b/gst/audiomixer/gstaudiomixer.c @@ -1424,11 +1424,9 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads, else out_start = 0; - if (audiomixer->offset + audiomixer->blocksize + adata->position / bpf < - adata->output_offset + adata->size / bpf + out_start) + overlap = adata->size / bpf - adata->position / bpf; + if (overlap > audiomixer->blocksize - out_start) overlap = audiomixer->blocksize - out_start; - else - overlap = adata->size / bpf - adata->position / bpf; inbuf = gst_collect_pads_peek (pads, collect_data); g_assert (inbuf != NULL && inbuf == adata->buffer); @@ -1441,6 +1439,8 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads, adata->output_offset += adata->size / bpf; if (adata->position >= adata->size) { /* Buffer done, drop it */ + adata->position = 0; + adata->size = 0; gst_buffer_replace (&adata->buffer, NULL); gst_buffer_unref (gst_collect_pads_pop (pads, collect_data)); }