Skip to content
This repository
Browse code

Merge pull request #2061 from davilla/vamp-fixes

VampireAE fixes, mmm'kay
  • Loading branch information...
commit 637279d99ab8ead26ba74f3607cca4ad93a879dd 2 parents a689ba1 + 34b240e
davilla authored
31  xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
@@ -935,7 +935,11 @@ double CSoftAE::GetCacheTotal()
935 935
 
936 936
 bool CSoftAE::IsSuspended()
937 937
 {
  938
+#if defined(TARGET_WINDOWS)
938 939
   return m_isSuspended;
  940
+#else
  941
+  return false;
  942
+#endif
939 943
 }
940 944
 
941 945
 float CSoftAE::GetVolume()
@@ -968,8 +972,8 @@ void CSoftAE::StopAllSounds()
968 972
 bool CSoftAE::Suspend()
969 973
 {
970 974
   CLog::Log(LOGDEBUG, "CSoftAE::Suspend - Suspending AE processing");
  975
+#if defined(TARGET_WINDOWS)
971 976
   m_isSuspended = true;
972  
-
973 977
   CSingleLock streamLock(m_streamLock);
974 978
   
975 979
   for (StreamList::iterator itt = m_playingStreams.begin(); itt != m_playingStreams.end(); ++itt)
@@ -977,6 +981,7 @@ bool CSoftAE::Suspend()
977 981
     CSoftAEStream *stream = *itt;
978 982
     stream->Flush();
979 983
   }
  984
+#endif
980 985
 
981 986
   return true;
982 987
 }
@@ -984,8 +989,10 @@ bool CSoftAE::Suspend()
984 989
 bool CSoftAE::Resume()
985 990
 {
986 991
   CLog::Log(LOGDEBUG, "CSoftAE::Resume - Resuming AE processing");
  992
+#if defined(TARGET_WINDOWS)
987 993
   m_isSuspended = false;
988 994
   m_reOpen = true;
  995
+#endif
989 996
 
990 997
   return true;
991 998
 }
@@ -1021,7 +1028,7 @@ void CSoftAE::Run()
1021 1028
         restart = true;
1022 1029
     }
1023 1030
 
1024  
-#if !defined(TARGET_ANDROID)
  1031
+#if defined(TARGET_WINDOWS)
1025 1032
     /* Handle idle or forced suspend */
1026 1033
     ProcessSuspend();
1027 1034
 #endif
@@ -1033,6 +1040,17 @@ void CSoftAE::Run()
1033 1040
       InternalOpenSink();
1034 1041
       m_isSuspended = false; // exit Suspend state
1035 1042
     }
  1043
+#if defined(TARGET_ANDROID)
  1044
+    else if (m_playingStreams.empty() 
  1045
+      &&     m_playing_sounds.empty()
  1046
+      && !g_advancedSettings.m_streamSilence)
  1047
+    {
  1048
+      // if we have nothing to do, take a dirt nap.
  1049
+      // we do not have to take a lock just to check empty.
  1050
+      // this keeps AE from sucking CPU if nothing is going on.
  1051
+      m_wake.WaitMSec(SOFTAE_IDLE_WAIT_MSEC);
  1052
+    }
  1053
+#endif
1036 1054
   }
1037 1055
 }
1038 1056
 
@@ -1388,15 +1406,18 @@ inline void CSoftAE::RemoveStream(StreamList &streams, CSoftAEStream *stream)
1388 1406
 inline void CSoftAE::ProcessSuspend()
1389 1407
 {
1390 1408
   bool sinkIsSuspended = false;
  1409
+  unsigned int curSystemClock = 0;
1391 1410
 
1392  
-  if (m_playingStreams.empty() && m_playing_sounds.empty() && 
1393  
-     !m_softSuspend && !g_advancedSettings.m_streamSilence)
  1411
+  if (!m_softSuspend && m_playingStreams.empty() && m_playing_sounds.empty() &&
  1412
+      !g_advancedSettings.m_streamSilence)
1394 1413
   {
1395 1414
     m_softSuspend = true;
1396 1415
     m_softSuspendTimer = XbmcThreads::SystemClockMillis() + 10000; //10.0 second delay for softSuspend
  1416
+    Sleep(10);
1397 1417
   }
1398 1418
 
1399  
-  unsigned int curSystemClock = XbmcThreads::SystemClockMillis();
  1419
+  if (m_softSuspend)
  1420
+    curSystemClock = XbmcThreads::SystemClockMillis();
1400 1421
 
1401 1422
   /* idle while in Suspend() state until Resume() called */
1402 1423
   /* idle if nothing to play and user hasn't enabled     */
3  xbmc/powermanagement/PowerManager.cpp
@@ -21,6 +21,7 @@
21 21
 #include "system.h"
22 22
 #include "PowerManager.h"
23 23
 #include "Application.h"
  24
+#include "cores/AudioEngine/AEFactory.h"
24 25
 #include "input/KeyboardStat.h"
25 26
 #include "settings/GUISettings.h"
26 27
 #include "windowing/WindowingFactory.h"
@@ -206,6 +207,7 @@ void CPowerManager::OnSleep()
206 207
   g_application.StopPlaying();
207 208
   g_application.StopShutdownTimer();
208 209
   g_application.StopScreenSaverTimer();
  210
+  CAEFactory::Suspend();
209 211
 }
210 212
 
211 213
 void CPowerManager::OnWake()
@@ -245,6 +247,7 @@ void CPowerManager::OnWake()
245 247
   g_lcd->Initialize();
246 248
 #endif
247 249
 
  250
+  CAEFactory::Resume();
248 251
   g_application.UpdateLibraries();
249 252
   g_weatherManager.Refresh();
250 253
 

0 notes on commit 637279d

Please sign in to comment.
Something went wrong with that request. Please try again.