banshee r4382 - in trunk/banshee: . src/Dap/Banshee.Dap/Banshee.Dap



Author: gburt
Date: Fri Aug 15 21:27:52 2008
New Revision: 4382
URL: http://svn.gnome.org/viewvc/banshee?rev=4382&view=rev

Log:
2008-08-15  Gabriel Burt  <gabriel burt gmail com>

	* src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs: Be more careful about
	what we do inside lock().  Do actual interaction with SourceManager
	outside the lock() for Map/Unmap dap functions.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	Fri Aug 15 21:27:52 2008
@@ -143,6 +143,7 @@
         private void MapDevice (IDevice device)
         {
             Banshee.Kernel.Scheduler.Schedule (new Banshee.Kernel.DelegateJob (delegate {
+                DapSource source = null;
                 lock (sync) {
                     try {
                         if (sources.ContainsKey (device.Uuid)) {
@@ -161,29 +162,40 @@
                             return;
                         }
                         
-                        DapSource source = FindDeviceSource (device);
+                        source = FindDeviceSource (device);
                         if (source != null) {
                             Log.DebugFormat ("Found DAP support ({0}) for device {1}", source.GetType ().FullName, source.Name);
                             sources.Add (device.Uuid, source);
-                            ServiceManager.SourceManager.AddSource (source);
-                            source.NotifyUser ();
                         }
                     } catch (Exception e) {
                         Log.Exception (e);
                     }
                 }
+
+                if (source != null) {
+                    ServiceManager.SourceManager.AddSource (source);
+                    source.NotifyUser ();
+                }
             }));
         }
         
         internal void UnmapDevice (string uuid)
         {
+            DapSource source = null;
             lock (sync) {
                 if (sources.ContainsKey (uuid)) {
                     Log.DebugFormat ("Unmapping DAP source ({0})", uuid);
-                    DapSource source = sources[uuid];
-                    source.Dispose ();
+                    source = sources[uuid];
                     sources.Remove (uuid);
+                }
+            }
+
+            if (source != null) {
+                try {
+                    source.Dispose ();
                     ServiceManager.SourceManager.RemoveSource (source);
+                } catch (Exception e) {
+                    Log.Exception (e);
                 }
             }
         }
@@ -192,9 +204,7 @@
         {
             DapSource dap_source = args.Source as DapSource;
             if (dap_source != null) {
-                lock (sync) {
-                    UnmapDevice (dap_source.Device.Uuid);
-                }
+                UnmapDevice (dap_source.Device.Uuid);
             }
         }
         



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]