From e0c9b045387b9b174fe5a42fa28c9075fb871f78 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Mon, 14 Jan 2019 16:22:16 +0800 Subject: [PATCH] deviceprovider: fix counting number of times started GstDeviceProvider has a started_count private variable counter, and the gst_device_provider_start() documentation emphasizes the importance of balancing the start and stop calls. However, when starting a provider that is already started, the current code will never increment the counter more than once. So you start it twice, but it will have start_count 1, which is the maximum value it will ever see. Then when you stop it twice, on the 2nd stop, after decrementing the counter in gst_device_provider_stop(): else if (provider->priv->started_count < 1) { g_critical ("Trying to stop a GstDeviceProvider %s which is already stopped", GST_OBJECT_NAME (provider)); and the program is killed. Fix this by incrementing the counter when starting a device provider that was already started. --- gst/gstdeviceprovider.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gst/gstdeviceprovider.c b/gst/gstdeviceprovider.c index 22b5a9b15e..2e0b55d15e 100644 --- a/gst/gstdeviceprovider.c +++ b/gst/gstdeviceprovider.c @@ -454,6 +454,7 @@ gst_device_provider_start (GstDeviceProvider * provider) g_mutex_lock (&provider->priv->start_lock); if (provider->priv->started_count > 0) { + provider->priv->started_count++; ret = TRUE; goto started; }