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>
gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
gboolean timeout)
{
gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
gboolean timeout)
{
+ GstFlvMux *mux = GST_FLV_MUX (aggregator);
GstFlvMuxPad *best = NULL;
GstFlvMuxPad *best = NULL;
GstClockTime best_ts = GST_CLOCK_TIME_NONE;
GstIterator *pads;
GValue padptr = { 0, };
GstClockTime best_ts = GST_CLOCK_TIME_NONE;
GstIterator *pads;
GValue padptr = { 0, };
while (!done) {
switch (gst_iterator_next (pads, &padptr)) {
case GST_ITERATOR_OK:{
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);
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) {
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;
best_ts = GST_CLOCK_TIME_NONE;
}
if (fpad->drop_deltas) {
}
if (fpad->drop_deltas) {
"Dropped buffer %" GST_PTR_FORMAT " until keyframe", buffer);
gst_buffer_unref (buffer);
gst_aggregator_pad_drop_buffer (apad);
"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;
best_ts = GST_CLOCK_TIME_NONE;
} else {
/* drop-deltas is set and the buffer isn't delta, drop flag */
fpad->drop_deltas = FALSE;
} else {
/* drop-deltas is set and the buffer isn't delta, drop flag */
fpad->drop_deltas = FALSE;
gst_aggregator_pad_drop_buffer (apad);
/* Look for non-delta buffer */
fpad->drop_deltas = TRUE;
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;
best_ts = GST_CLOCK_TIME_NONE;
best_ts = t;
}
gst_buffer_unref (buffer);
best_ts = t;
}
gst_buffer_unref (buffer);
- g_value_reset (&padptr);
break;
}
case GST_ITERATOR_DONE:
break;
}
case GST_ITERATOR_DONE:
g_assert_not_reached ();
break;
}
g_assert_not_reached ();
break;
}
+ g_value_reset (&padptr);
}
g_value_unset (&padptr);
gst_iterator_free (pads);
}
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;
if (ts)
*ts = best_ts;
return best;