audiomixer: use new gst_aggregator_pad_drop_buffer()

This commit is contained in:
Tim-Philipp Müller 2015-02-13 16:06:34 +00:00
parent 54d288fc19
commit 84a9493a81

View file

@ -1071,14 +1071,10 @@ gst_audio_mixer_fill_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad,
gst_util_uint64_scale (end_running_time, rate, GST_SECOND); gst_util_uint64_scale (end_running_time, rate, GST_SECOND);
if (end_running_time_offset < audiomixer->offset) { if (end_running_time_offset < audiomixer->offset) {
GstBuffer *buf;
/* Before output segment, drop */ /* Before output segment, drop */
gst_buffer_unref (inbuf); gst_buffer_unref (inbuf);
pad->buffer = NULL; pad->buffer = NULL;
buf = gst_aggregator_pad_steal_buffer (aggpad); gst_aggregator_pad_drop_buffer (aggpad);
if (buf)
gst_buffer_unref (buf);
pad->position = 0; pad->position = 0;
pad->size = 0; pad->size = 0;
pad->output_offset = -1; pad->output_offset = -1;
@ -1089,7 +1085,6 @@ gst_audio_mixer_fill_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad,
} }
if (start_running_time_offset < audiomixer->offset) { if (start_running_time_offset < audiomixer->offset) {
GstBuffer *buf;
guint diff = (audiomixer->offset - start_running_time_offset) * bpf; guint diff = (audiomixer->offset - start_running_time_offset) * bpf;
pad->position += diff; pad->position += diff;
@ -1097,9 +1092,7 @@ gst_audio_mixer_fill_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad,
/* Empty buffer, drop */ /* Empty buffer, drop */
gst_buffer_unref (inbuf); gst_buffer_unref (inbuf);
pad->buffer = NULL; pad->buffer = NULL;
buf = gst_aggregator_pad_steal_buffer (aggpad); gst_aggregator_pad_drop_buffer (aggpad);
if (buf)
gst_buffer_unref (buf);
pad->position = 0; pad->position = 0;
pad->size = 0; pad->size = 0;
pad->output_offset = -1; pad->output_offset = -1;
@ -1166,28 +1159,22 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad,
pad->position += overlap * bpf; pad->position += overlap * bpf;
pad->output_offset += overlap; pad->output_offset += overlap;
if (pad->position >= pad->size) { if (pad->position >= pad->size) {
GstBuffer *buf;
/* Buffer done, drop it */ /* Buffer done, drop it */
gst_buffer_replace (&pad->buffer, NULL); gst_buffer_replace (&pad->buffer, NULL);
buf = gst_aggregator_pad_steal_buffer (aggpad); gst_aggregator_pad_drop_buffer (aggpad);
if (buf)
gst_buffer_unref (buf);
} }
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
return; return;
} }
if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) { if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
GstBuffer *aggpadbuf = gst_aggregator_pad_steal_buffer (aggpad);
/* skip gap buffer */ /* skip gap buffer */
GST_LOG_OBJECT (pad, "skipping GAP buffer"); GST_LOG_OBJECT (pad, "skipping GAP buffer");
gst_buffer_unref (inbuf); gst_buffer_unref (inbuf);
pad->output_offset += pad->size / bpf; pad->output_offset += pad->size / bpf;
/* Buffer done, drop it */ /* Buffer done, drop it */
gst_buffer_replace (&pad->buffer, NULL); gst_buffer_replace (&pad->buffer, NULL);
if (aggpadbuf) gst_aggregator_pad_drop_buffer (aggpad);
gst_buffer_unref (aggpadbuf);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
return; return;
} }
@ -1296,13 +1283,9 @@ gst_audio_mixer_mix_buffer (GstAudioMixer * audiomixer, GstAudioMixerPad * pad,
pad->output_offset += overlap; pad->output_offset += overlap;
if (pad->position == pad->size) { if (pad->position == pad->size) {
GstBuffer *buf;
/* Buffer done, drop it */ /* Buffer done, drop it */
gst_buffer_replace (&pad->buffer, NULL); gst_buffer_replace (&pad->buffer, NULL);
buf = gst_aggregator_pad_steal_buffer (aggpad); gst_aggregator_pad_drop_buffer (aggpad);
if (buf)
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (pad, "Finished mixing buffer, waiting for next"); GST_DEBUG_OBJECT (pad, "Finished mixing buffer, waiting for next");
} }
@ -1475,13 +1458,9 @@ gst_audiomixer_aggregate (GstAggregator * agg, gboolean timeout)
pad->output_offset += diff; pad->output_offset += diff;
if (pad->position == pad->size) { if (pad->position == pad->size) {
GstBuffer *buf;
/* Buffer done, drop it */ /* Buffer done, drop it */
gst_buffer_replace (&pad->buffer, NULL); gst_buffer_replace (&pad->buffer, NULL);
buf = gst_aggregator_pad_steal_buffer (aggpad); gst_aggregator_pad_drop_buffer (aggpad);
if (buf)
gst_buffer_unref (buf);
dropped = TRUE; dropped = TRUE;
continue; continue;
} }