webrtc: fix an off-by-one calculating low-threshold

We were not signalling low-threshold when the previous amount was at
exactly the low-threshold mark.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1247>
This commit is contained in:
Matthew Waters 2020-05-06 15:36:19 +10:00
parent d0b20f8bba
commit 02c8e66ff1
2 changed files with 8 additions and 2 deletions

View file

@ -527,7 +527,9 @@ _parse_control_packet (GstWebRTCDataChannel * channel, guint8 * data,
g_set_error (error, GST_WEBRTC_BIN_ERROR,
GST_WEBRTC_BIN_ERROR_DATA_CHANNEL_FAILURE,
"Could not send ack packet");
return ret;
}
return ret;
} else {
g_set_error (error, GST_WEBRTC_BIN_ERROR,
@ -1042,7 +1044,11 @@ on_appsrc_data (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
CHANNEL_LOCK (channel);
prev_amount = channel->buffered_amount;
channel->buffered_amount -= size;
if (prev_amount > channel->buffered_amount_low_threshold &&
GST_TRACE_OBJECT (channel, "checking low-threshold: prev %"
G_GUINT64_FORMAT " low-threshold %" G_GUINT64_FORMAT " buffered %"
G_GUINT64_FORMAT, prev_amount, channel->buffered_amount_low_threshold,
channel->buffered_amount);
if (prev_amount >= channel->buffered_amount_low_threshold &&
channel->buffered_amount < channel->buffered_amount_low_threshold) {
_channel_enqueue_task (channel, (ChannelTask) _emit_low_threshold,
NULL, NULL);

View file

@ -1846,7 +1846,7 @@ have_data_channel_check_low_threshold_emitted (struct test_webrtc *t,
g_signal_connect (our, "on-error", G_CALLBACK (on_channel_error_not_reached),
NULL);
g_signal_emit_by_name (our, "send-string", "DATA");
g_signal_emit_by_name (our, "send-string", "A");
}
GST_START_TEST (test_data_channel_low_threshold)