diff options
author | Mathieu Duponchelle <mathieu.duponchelle@epitech.eu> | 2013-09-22 22:55:33 +0200 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-09-24 10:04:37 +0200 |
commit | 663f71a5ddfcf75adbc857fb1c275f82e6e5dbe9 (patch) | |
tree | b4064ba6cae43adc3ab22077c1b72fde1df6accf | |
parent | 30a0cccbf6356a59adcc3cef26aa828252a81989 (diff) |
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
-rw-r--r-- | gst/adder/gstadder.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 74310a0fd..e0e7b7694 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -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; |