adder: send pending segment out before checking for EOS

Otherwise there would be cases where it would not send its segment
out when the first collected after getting it would already yield EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=708590
This commit is contained in:
Mathieu Duponchelle 2013-09-22 22:55:33 +02:00 committed by Sebastian Dröge
parent 30a0cccbf6
commit 663f71a5dd

View file

@ -1183,6 +1183,41 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
adder->send_caps = FALSE;
}
rate = GST_AUDIO_INFO_RATE (&adder->info);
bps = GST_AUDIO_INFO_BPS (&adder->info);
bpf = GST_AUDIO_INFO_BPF (&adder->info);
if (g_atomic_int_compare_and_exchange (&adder->new_segment_pending, TRUE,
FALSE)) {
GstEvent *event;
/*
* When seeking we set the start and stop positions as given in the seek
* event. We also adjust offset & timestamp accordingly.
* This basically ignores all newsegments sent by upstream.
*/
event = gst_event_new_segment (&adder->segment);
if (adder->segment.rate > 0.0) {
adder->segment.position = adder->segment.start;
} else {
adder->segment.position = adder->segment.stop;
}
adder->offset = gst_util_uint64_scale (adder->segment.position,
rate, GST_SECOND);
GST_INFO_OBJECT (adder->srcpad, "sending pending new segment event %"
GST_SEGMENT_FORMAT, &adder->segment);
if (event) {
if (!gst_pad_push_event (adder->srcpad, event)) {
GST_WARNING_OBJECT (adder->srcpad, "Sending new segment event failed");
}
} else {
GST_WARNING_OBJECT (adder->srcpad, "Creating new segment event for "
"start:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " failed",
adder->segment.start, adder->segment.stop);
}
}
/* get available bytes for reading, this can be 0 which could mean empty
* buffers or EOS, which we will catch when we loop over the pads. */
outsize = gst_collect_pads_available (pads);
@ -1190,10 +1225,6 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
if (outsize == 0)
goto eos;
rate = GST_AUDIO_INFO_RATE (&adder->info);
bps = GST_AUDIO_INFO_BPS (&adder->info);
bpf = GST_AUDIO_INFO_BPF (&adder->info);
GST_LOG_OBJECT (adder,
"starting to cycle through channels, %d bytes available (bps = %d, bpf = %d)",
outsize, bps, bpf);
@ -1433,37 +1464,6 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
gst_buffer_unref (gapbuf);
}
if (g_atomic_int_compare_and_exchange (&adder->new_segment_pending, TRUE,
FALSE)) {
GstEvent *event;
/*
* When seeking we set the start and stop positions as given in the seek
* event. We also adjust offset & timestamp accordingly.
* This basically ignores all newsegments sent by upstream.
*/
event = gst_event_new_segment (&adder->segment);
if (adder->segment.rate > 0.0) {
adder->segment.position = adder->segment.start;
} else {
adder->segment.position = adder->segment.stop;
}
adder->offset = gst_util_uint64_scale (adder->segment.position,
rate, GST_SECOND);
GST_INFO_OBJECT (adder->srcpad, "sending pending new segment event %"
GST_SEGMENT_FORMAT, &adder->segment);
if (event) {
if (!gst_pad_push_event (adder->srcpad, event)) {
GST_WARNING_OBJECT (adder->srcpad, "Sending new segment event failed");
}
} else {
GST_WARNING_OBJECT (adder->srcpad, "Creating new segment event for "
"start:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " failed",
adder->segment.start, adder->segment.stop);
}
}
if (G_UNLIKELY (adder->pending_events)) {
GList *tmp = adder->pending_events;