[banshee] [Banshee.Dap] Optimize initialization



commit 9cb4e2353ffb7dbbf616a58c32e2bf63ae3560d1
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Dec 10 15:24:08 2009 -0800

    [Banshee.Dap] Optimize initialization
    
    When initializing, wait for the DAP support extensions to be loaded, and
    then check all devices against them; reduces number of device checks by
    2/3.

 src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
index 0356540..9b1de00 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
@@ -72,6 +72,11 @@ namespace Banshee.Dap
                 ServiceManager.HardwareManager.DeviceCommand += OnDeviceCommand;
                 ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
                 initialized = true;
+
+                // Now that we've loaded all the enabled DAP providers, load the devices
+                foreach (IDevice device in ServiceManager.HardwareManager.GetAllDevices ()) {
+                    MapDevice (device);
+                }
             }
         }
 
@@ -84,9 +89,11 @@ namespace Banshee.Dap
                     Log.DebugFormat ("Dap support extension loaded: {0}", node.Addin.Id);
                     supported_dap_types.Add (node);
 
-                    // See if any existing devices are handled by this new DAP support
-                    foreach (IDevice device in ServiceManager.HardwareManager.GetAllDevices ()) {
-                        MapDevice (device);
+                    if (initialized) {
+                        // See if any existing devices are handled by this new DAP support
+                        foreach (IDevice device in ServiceManager.HardwareManager.GetAllDevices ()) {
+                            MapDevice (device);
+                        }
                     }
                 } else if (args.Change == ExtensionChange.Remove) {
                     supported_dap_types.Remove (node);



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