tests/webrtcbin: Add a lock around the stats test

Prevent any race if both webrtcbin end up generating their
statistics simultaneously, however unlikely.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7365>
This commit is contained in:
Jan Schmidt 2024-08-16 14:47:52 +10:00 committed by GStreamer Marge Bot
parent 460f5dcb33
commit d266995323

View file

@ -1829,9 +1829,13 @@ _on_stats (GstPromise * promise, gpointer user_data)
int i; int i;
validate_stats (reply); validate_stats (reply);
g_mutex_lock (&t->lock);
i = GPOINTER_TO_INT (t->user_data); i = GPOINTER_TO_INT (t->user_data);
i++; i++;
t->user_data = GINT_TO_POINTER (i); t->user_data = GINT_TO_POINTER (i);
g_mutex_unlock (&t->lock);
if (i >= 2) if (i >= 2)
test_webrtc_signal_state (t, STATE_CUSTOM); test_webrtc_signal_state (t, STATE_CUSTOM);