uvcsink: refactor gst_uvc_sink_update_streaming

Move the sanity checks to the beginning of the function. Make the actual effect
of the function more obvious and reset the flags in the end.

This should make it easier to understand what this function is doing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4994>
This commit is contained in:
Michael Tretter 2023-07-19 11:22:03 +02:00 committed by GStreamer Marge Bot
parent 6637343980
commit 1732f8c728

View file

@ -230,20 +230,16 @@ static GstPadProbeReturn gst_uvc_sink_sinkpad_event_peer_probe (GstPad * pad,
static void
gst_uvc_sink_update_streaming (GstUvcSink * self)
{
if (self->streamon) {
g_atomic_int_set (&self->streamon, FALSE);
if (self->streamon && !self->streaming)
GST_ERROR_OBJECT (self, "Unexpected STREAMON");
if (self->streamoff && self->streaming)
GST_ERROR_OBJECT (self, "Unexpected STREAMOFF");
if (self->streamon)
gst_uvc_sink_to_v4l2sink (self);
if (!self->streaming)
GST_DEBUG_OBJECT (self, "something went wrong!");
}
if (self->streamoff) {
g_atomic_int_set (&self->streamoff, FALSE);
if (self->streaming)
GST_DEBUG_OBJECT (self, "something went wrong!");
}
g_atomic_int_set (&self->streamon, FALSE);
g_atomic_int_set (&self->streamoff, FALSE);
}
static gboolean