summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-12-23 12:24:48 +0100
committerSebastian Dröge <sebastian@centricular.com>2014-12-23 12:24:48 +0100
commitbe7034d1f77444e069580ef2c0367d03bd150126 (patch)
tree4ff8507f26318b92db13137d610845ef0ef4ec27 /gst
parent0e8604f4eee5abde1e6e83f0805b519c7746d737 (diff)
audiomixer: If getting a timeout before having caps, just advance our position
This can happen if this is a live pipeline and no source produced any buffer and sent no caps until the an output buffer should've been produced according to the latency.
Diffstat (limited to 'gst')
-rw-r--r--gst/audiomixer/gstaudiomixer.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/gst/audiomixer/gstaudiomixer.c b/gst/audiomixer/gstaudiomixer.c
index a12a3f1b3..35e6cc0ff 100644
--- a/gst/audiomixer/gstaudiomixer.c
+++ b/gst/audiomixer/gstaudiomixer.c
@@ -707,7 +707,11 @@ gst_audiomixer_sink_event (GstAggregator * agg, GstAggregatorPad * aggpad,
static void
gst_audiomixer_reset (GstAudioMixer * audiomixer)
{
+ GstAggregator *agg = GST_AGGREGATOR (audiomixer);
+
audiomixer->offset = 0;
+ agg->segment.position = -1;
+
gst_caps_replace (&audiomixer->current_caps, NULL);
gst_buffer_replace (&audiomixer->current_buffer, NULL);
}
@@ -1375,9 +1379,32 @@ gst_audiomixer_aggregate (GstAggregator * agg, gboolean timeout)
audiomixer = GST_AUDIO_MIXER (agg);
- /* this is fatal */
- if (G_UNLIKELY (audiomixer->info.finfo->format == GST_AUDIO_FORMAT_UNKNOWN))
- goto not_negotiated;
+ /* Update position from the segment start/stop if needed */
+ if (agg->segment.position == -1) {
+ if (agg->segment.rate > 0.0)
+ agg->segment.position = agg->segment.start;
+ else
+ agg->segment.position = agg->segment.stop;
+ }
+
+ if (G_UNLIKELY (audiomixer->info.finfo->format == GST_AUDIO_FORMAT_UNKNOWN)) {
+ if (timeout) {
+ GST_DEBUG_OBJECT (audiomixer,
+ "Got timeout before receiving any caps, don't output anything");
+
+ /* Advance position */
+ if (agg->segment.rate > 0.0)
+ agg->segment.position += audiomixer->output_buffer_duration;
+ else if (agg->segment.position > audiomixer->output_buffer_duration)
+ agg->segment.position -= audiomixer->output_buffer_duration;
+ else
+ agg->segment.position = 0;
+
+ return GST_FLOW_OK;
+ } else {
+ goto not_negotiated;
+ }
+ }
blocksize =
gst_util_uint64_scale (audiomixer->output_buffer_duration,
@@ -1387,11 +1414,6 @@ gst_audiomixer_aggregate (GstAggregator * agg, gboolean timeout)
if (audiomixer->send_caps) {
gst_aggregator_set_src_caps (agg, audiomixer->current_caps);
- if (agg->segment.rate > 0.0)
- agg->segment.position = agg->segment.start;
- else
- agg->segment.position = agg->segment.stop;
-
audiomixer->offset = gst_util_uint64_scale (agg->segment.position,
GST_AUDIO_INFO_RATE (&audiomixer->info), GST_SECOND);