Blob Blame Raw
From 2a27acbbb6786e8a9b35e1c483ceb9dc5b097839 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 18 Jun 2013 13:45:38 +0200
Subject: [PATCH 07/11] cheese: Avoid unnecessary calls to
 switch_camera_device()

And thus avoid stopping and restarting the stream for no reason.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/cheese-preferences.vala | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index 06929f5..723a916 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -26,6 +26,7 @@ public class Cheese.PreferencesDialog : GLib.Object
   private Cheese.Camera camera;
   private bool camera_is_setup;
   private bool camera_is_playing;
+  private string camera_device_node;
 
   private GLib.Settings settings;
 
@@ -178,7 +179,8 @@ public class Cheese.PreferencesDialog : GLib.Object
     device = camera.get_selected_device ();
     if (device == null)
       return;
-    settings.set_string ("camera", device.get_device_node ());
+    camera_device_node = device.get_device_node ();
+    settings.set_string ("camera", camera_device_node);
     setup_resolutions_for_device (device);
 
     for (bool next = camera_model.get_iter_first (out iter); next;
@@ -281,10 +283,16 @@ public class Cheese.PreferencesDialog : GLib.Object
 
     TreeIter iter;
     Cheese.CameraDevice dev;
+    string dev_node;
 
     combo.get_active_iter (out iter);
     combo.model.get (iter, 1, out dev);
-    camera.set_device_by_device_node (dev.get_device_node ());
+    dev_node = dev.get_device_node ();
+
+    if (dev_node == camera_device_node)
+      return;
+
+    camera.set_device_by_device_node (dev_node);
     camera.switch_camera_device ();
     camera_play ();
   }
-- 
1.8.3.1