Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gst-plugins-good.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2020-08-31 14:43:42 +0300
committerJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2020-08-31 16:14:56 +0300
commit01594d19b8dfac38226910d1b10231c26133c7f9 (patch)
treeb5653d5fbd5f92274e5a82d68a067a97bdcff4e0 /gst
parente69599150844b8136c87dd5a130278d6a1f8e02c (diff)
flvmux: Correct breaks in gst_flv_mux_find_best_pad
The code seems to use `continue` and `break` as if both refer to the surrounding `while` loop. But because `break` breaks out of the `switch`, they actually have the same effect. This may have caused the loop not to terminate when it should. E.g. when `skip_backwards_streams` drops a buffer we should abort the aggregation and wait for all pads to be filled again. Instead, we might have just selected a subsequent pad as our new "best". Replace `break` with `done = TRUE; break`, and `continue` with `break`. Then simplify the code a bit. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/710>
Diffstat (limited to 'gst')
-rw-r--r--gst/flv/gstflvmux.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c
index 71ecd7aeb..8b9e73283 100644
--- a/gst/flv/gstflvmux.c
+++ b/gst/flv/gstflvmux.c
@@ -1853,8 +1853,8 @@ static GstFlvMuxPad *
gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
gboolean timeout)
{
+ GstFlvMux *mux = GST_FLV_MUX (aggregator);
GstFlvMuxPad *best = NULL;
- GstBuffer *buffer;
GstClockTime best_ts = GST_CLOCK_TIME_NONE;
GstIterator *pads;
GValue padptr = { 0, };
@@ -1865,22 +1865,19 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
while (!done) {
switch (gst_iterator_next (pads, &padptr)) {
case GST_ITERATOR_OK:{
-
- GstFlvMux *mux = GST_FLV_MUX (aggregator);
GstAggregatorPad *apad = g_value_get_object (&padptr);
GstFlvMuxPad *fpad = GST_FLV_MUX_PAD (apad);
- gint64 t = GST_CLOCK_TIME_NONE;
+ GstClockTime t = GST_CLOCK_TIME_NONE;
+ GstBuffer *buffer;
buffer = gst_aggregator_pad_peek_buffer (apad);
if (!buffer) {
- if (timeout || GST_PAD_IS_EOS (apad)) {
- continue;
- } else {
- if (best)
- gst_object_replace ((GstObject **) & best, NULL);
+ if (!timeout && !GST_PAD_IS_EOS (apad)) {
+ gst_object_replace ((GstObject **) & best, NULL);
best_ts = GST_CLOCK_TIME_NONE;
- break;
+ done = TRUE;
}
+ break;
}
if (fpad->drop_deltas) {
@@ -1890,14 +1887,12 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
"Dropped buffer %" GST_PTR_FORMAT " until keyframe", buffer);
gst_buffer_unref (buffer);
gst_aggregator_pad_drop_buffer (apad);
- if (timeout) {
- continue;
- } else {
- if (best)
- gst_object_replace ((GstObject **) & best, NULL);
+ if (!timeout) {
+ gst_object_replace ((GstObject **) & best, NULL);
best_ts = GST_CLOCK_TIME_NONE;
- break;
+ done = TRUE;
}
+ break;
} else {
/* drop-deltas is set and the buffer isn't delta, drop flag */
fpad->drop_deltas = FALSE;
@@ -1918,14 +1913,12 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
gst_aggregator_pad_drop_buffer (apad);
/* Look for non-delta buffer */
fpad->drop_deltas = TRUE;
- if (timeout) {
- continue;
- } else {
- if (best)
- gst_object_replace ((GstObject **) & best, NULL);
+ if (!timeout) {
+ gst_object_replace ((GstObject **) & best, NULL);
best_ts = GST_CLOCK_TIME_NONE;
- break;
+ done = TRUE;
}
+ break;
}
}
@@ -1935,7 +1928,6 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
best_ts = t;
}
gst_buffer_unref (buffer);
- g_value_reset (&padptr);
break;
}
case GST_ITERATOR_DONE:
@@ -1952,13 +1944,19 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
g_assert_not_reached ();
break;
}
+ g_value_reset (&padptr);
}
g_value_unset (&padptr);
gst_iterator_free (pads);
- GST_DEBUG_OBJECT (aggregator,
- "Best pad found with %" GST_TIME_FORMAT ": %" GST_PTR_FORMAT,
- GST_TIME_ARGS (best_ts), best);
+ if (best) {
+ GST_DEBUG_OBJECT (aggregator,
+ "Best pad found with TS %" GST_TIME_FORMAT ": %" GST_PTR_FORMAT,
+ GST_TIME_ARGS (best_ts), best);
+ } else {
+ GST_DEBUG_OBJECT (aggregator, "Best pad not found");
+ }
+
if (ts)
*ts = best_ts;
return best;