Commit aa3eb10c authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

audiomixer: Fix and simplify overlap calculation

parent 078b82d6
...@@ -1424,11 +1424,9 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads, ...@@ -1424,11 +1424,9 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads,
else else
out_start = 0; out_start = 0;
if (audiomixer->offset + audiomixer->blocksize + adata->position / bpf < overlap = adata->size / bpf - adata->position / bpf;
adata->output_offset + adata->size / bpf + out_start) if (overlap > audiomixer->blocksize - out_start)
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); inbuf = gst_collect_pads_peek (pads, collect_data);
g_assert (inbuf != NULL && inbuf == adata->buffer); g_assert (inbuf != NULL && inbuf == adata->buffer);
...@@ -1441,6 +1439,8 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads, ...@@ -1441,6 +1439,8 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstCollectPads * pads,
adata->output_offset += adata->size / bpf; adata->output_offset += adata->size / bpf;
if (adata->position >= adata->size) { if (adata->position >= adata->size) {
/* Buffer done, drop it */ /* Buffer done, drop it */
adata->position = 0;
adata->size = 0;
gst_buffer_replace (&adata->buffer, NULL); gst_buffer_replace (&adata->buffer, NULL);
gst_buffer_unref (gst_collect_pads_pop (pads, collect_data)); gst_buffer_unref (gst_collect_pads_pop (pads, collect_data));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment