From 1732f8c728eaded9791c1ebeb81c6b48e57f9531 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 19 Jul 2023 11:22:03 +0200 Subject: [PATCH] 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: --- .../sys/uvcgadget/gstuvcsink.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c b/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c index 710f1243cb..dd1fdbc9ff 100644 --- a/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c +++ b/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c @@ -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