Merge pull request #4425 from wsoltys/suspendinggb
authorjmarshallnz <jcmarsha@gmail.com>
Fri, 14 Mar 2014 20:22:07 +0000 (09:22 +1300)
committerjmarshallnz <jcmarsha@gmail.com>
Fri, 14 Mar 2014 20:22:07 +0000 (09:22 +1300)
[WIN32] changed: don't call CAEFactory::DeviceChange() when PBT_APMSUSPEND was sent.

xbmc/powermanagement/windows/Win32PowerSyscall.h
xbmc/win32/IMMNotificationClient.h

index 02eb11b..87d2a15 100644 (file)
@@ -45,6 +45,7 @@ public:
 
   static void SetOnResume() { m_OnResume = true; }
   static void SetOnSuspend() { m_OnSuspend = true; }
+  static bool IsSuspending() { return m_OnSuspend; }
 
 private:
 
index aa07537..f240b1b 100644 (file)
@@ -24,6 +24,7 @@
 #include "system.h" // for SAFE_RELEASE
 #include "utils/log.h"
 #include "cores/AudioEngine/AEFactory.h"
+#include "powermanagement/windows/Win32PowerSyscall.h"
 
 class CMMNotificationClient : public IMMNotificationClient
 {
@@ -107,7 +108,7 @@ public:
       break;
     case eCommunications:
       pszRole = "eCommunications";
-      CAEFactory::DeviceChange();
+      NotifyAE();
       break;
     }
 
@@ -118,14 +119,14 @@ public:
   HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId)
   {
     CLog::Log(LOGDEBUG, "%s: Added device: %s", __FUNCTION__, pwstrDeviceId);
-    CAEFactory::DeviceChange();
+    NotifyAE();
     return S_OK;
   }
 
   HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId)
   {
     CLog::Log(LOGDEBUG, "%s: Removed device: %s", __FUNCTION__, pwstrDeviceId);
-    CAEFactory::DeviceChange();
+    NotifyAE();
     return S_OK;
   }
 
@@ -149,7 +150,7 @@ public:
       break;
     }
     CLog::Log(LOGDEBUG, "%s: New device state is DEVICE_STATE_%s", __FUNCTION__, pszState);
-    CAEFactory::DeviceChange();
+    NotifyAE();
     return S_OK;
   }
 
@@ -164,4 +165,10 @@ public:
                                            key.pid);
     return S_OK;
   }
+
+  void STDMETHODCALLTYPE NotifyAE()
+  {
+    if(!CWin32PowerSyscall::IsSuspending())
+      CAEFactory::DeviceChange();
+  }
 };
\ No newline at end of file