summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-09-30 19:01:21 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-10-02 11:04:00 +0300
commit7d4bfcd8c9b42a99ab9ba3e7ae56d2e1f2132a66 (patch)
tree96cc3692be0d5ce7275f923d53fc96f728169118
parent86f6b83d7f4146baa6b92a8f7353e4a2d6daa746 (diff)
downloadgstreamer-plugins-bad-7d4bfcd8c9b42a99ab9ba3e7ae56d2e1f2132a66.tar.gz
audioaggregator: Select the initial offset based on the start segment position
instead of always using 0. Otherwise we might output a lot of silence in the beginning instead of outputting from the relevant position. https://bugzilla.gnome.org/show_bug.cgi?id=755623
-rw-r--r--gst/audiomixer/gstaudioaggregator.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gst/audiomixer/gstaudioaggregator.c b/gst/audiomixer/gstaudioaggregator.c
index 2afea27d4..2d65aa894 100644
--- a/gst/audiomixer/gstaudioaggregator.c
+++ b/gst/audiomixer/gstaudioaggregator.c
@@ -681,7 +681,7 @@ gst_audio_aggregator_reset (GstAudioAggregator * aagg)
GST_AUDIO_AGGREGATOR_LOCK (aagg);
GST_OBJECT_LOCK (aagg);
agg->segment.position = -1;
- aagg->priv->offset = 0;
+ aagg->priv->offset = -1;
gst_audio_info_init (&aagg->info);
gst_caps_replace (&aagg->current_caps, NULL);
gst_buffer_replace (&aagg->priv->current_buffer, NULL);
@@ -717,7 +717,7 @@ gst_audio_aggregator_flush (GstAggregator * agg)
GST_AUDIO_AGGREGATOR_LOCK (aagg);
GST_OBJECT_LOCK (aagg);
agg->segment.position = -1;
- aagg->priv->offset = 0;
+ aagg->priv->offset = -1;
gst_buffer_replace (&aagg->priv->current_buffer, NULL);
GST_OBJECT_UNLOCK (aagg);
GST_AUDIO_AGGREGATOR_UNLOCK (aagg);
@@ -1135,8 +1135,15 @@ gst_audio_aggregator_aggregate (GstAggregator * agg, gboolean timeout)
rate = GST_AUDIO_INFO_RATE (&aagg->info);
bpf = GST_AUDIO_INFO_BPF (&aagg->info);
+ if (aagg->priv->offset == -1) {
+ aagg->priv->offset =
+ gst_util_uint64_scale (agg->segment.position - agg->segment.start, rate,
+ GST_SECOND);
+ GST_DEBUG_OBJECT (aagg, "Starting at offset %lu", aagg->priv->offset);
+ }
+
blocksize = gst_util_uint64_scale (aagg->priv->output_buffer_duration,
- GST_AUDIO_INFO_RATE (&aagg->info), GST_SECOND);
+ rate, GST_SECOND);
blocksize = MAX (1, blocksize);
/* for the next timestamp, use the sample counter, which will