Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

VampireAE fixes, mmm'kay

  • Loading branch information...
commit 34b240e5caff49cd2a55c5be2a13d97ac8041c84 1 parent cdc73c3
@davilla davilla authored
View
31 xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
@@ -935,7 +935,11 @@ double CSoftAE::GetCacheTotal()
bool CSoftAE::IsSuspended()
{
+#if defined(TARGET_WINDOWS)
return m_isSuspended;
+#else
+ return false;
+#endif
}
float CSoftAE::GetVolume()
@@ -968,8 +972,8 @@ void CSoftAE::StopAllSounds()
bool CSoftAE::Suspend()
{
CLog::Log(LOGDEBUG, "CSoftAE::Suspend - Suspending AE processing");
+#if defined(TARGET_WINDOWS)
m_isSuspended = true;
-
CSingleLock streamLock(m_streamLock);
for (StreamList::iterator itt = m_playingStreams.begin(); itt != m_playingStreams.end(); ++itt)
@@ -977,6 +981,7 @@ bool CSoftAE::Suspend()
CSoftAEStream *stream = *itt;
stream->Flush();
}
+#endif
return true;
}
@@ -984,8 +989,10 @@ bool CSoftAE::Suspend()
bool CSoftAE::Resume()
{
CLog::Log(LOGDEBUG, "CSoftAE::Resume - Resuming AE processing");
+#if defined(TARGET_WINDOWS)
m_isSuspended = false;
m_reOpen = true;
+#endif
return true;
}
@@ -1021,7 +1028,7 @@ void CSoftAE::Run()
restart = true;
}
-#if !defined(TARGET_ANDROID)
+#if defined(TARGET_WINDOWS)
/* Handle idle or forced suspend */
ProcessSuspend();
#endif
@@ -1033,6 +1040,17 @@ void CSoftAE::Run()
InternalOpenSink();
m_isSuspended = false; // exit Suspend state
}
+#if defined(TARGET_ANDROID)
+ else if (m_playingStreams.empty()
+ && m_playing_sounds.empty()
+ && !g_advancedSettings.m_streamSilence)
+ {
+ // if we have nothing to do, take a dirt nap.
+ // we do not have to take a lock just to check empty.
+ // this keeps AE from sucking CPU if nothing is going on.
+ m_wake.WaitMSec(SOFTAE_IDLE_WAIT_MSEC);
+ }
+#endif
}
}
@@ -1388,15 +1406,18 @@ inline void CSoftAE::RemoveStream(StreamList &streams, CSoftAEStream *stream)
inline void CSoftAE::ProcessSuspend()
{
bool sinkIsSuspended = false;
+ unsigned int curSystemClock = 0;
- if (m_playingStreams.empty() && m_playing_sounds.empty() &&
- !m_softSuspend && !g_advancedSettings.m_streamSilence)
+ if (!m_softSuspend && m_playingStreams.empty() && m_playing_sounds.empty() &&
+ !g_advancedSettings.m_streamSilence)
{
m_softSuspend = true;
m_softSuspendTimer = XbmcThreads::SystemClockMillis() + 10000; //10.0 second delay for softSuspend
+ Sleep(10);
@jmarshallnz Owner

Why sleep here? My guess is that this is supposed to handle the case where the sink can't (or won't) suspend, where m_softSuspend is set back to false

Wouldn't it be better in the bit that sets m_softSuspend back to false (where we have the comment that the sink cannot be suspended)?

It won't drop into the While loop until 10 seconds of inactivity has passed, and this just slows the Run() loop and prevents hammering SystemClockMillis during that time. It also acts as a slowdown if the sink refuses to suspend and never hits the wait CEvent in the While loop.

@jmarshallnz Owner

Yup, I see it now that you point it out. Is it completely non-obvious from the fragmented code flow, or am I the only one?

This suggests documentation at least, or preferably a rewrite of the function to make the code path clear.

You're not the only one ;) This got even more fragmented after ALSA balked at short-duration suspends (on some systems). Writing it was rough and reading it worse.

Here's my understanding to date:

  • win32 works fine with both forced and soft suspend
  • ALSA works fine with forced suspend but balks with broken pipes whenever "paused" <- still gotta be a sink or kernal issue
  • Android,,,,,,does what?

Really it's just come full-circle after all this re-write for ALSA/Droid and I'm not sure anything's changed.....

@jmarshallnz Owner

That's not the problem. There are no ifdefs in the existing ProcessSuspend() function, yet it is non-obvious how the code flow goes. What needs to be done is to document how the process should be and then (re)write the code so that it does it in an obvious manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
- unsigned int curSystemClock = XbmcThreads::SystemClockMillis();
+ if (m_softSuspend)
+ curSystemClock = XbmcThreads::SystemClockMillis();
/* idle while in Suspend() state until Resume() called */
/* idle if nothing to play and user hasn't enabled */
View
3  xbmc/powermanagement/PowerManager.cpp
@@ -21,6 +21,7 @@
#include "system.h"
#include "PowerManager.h"
#include "Application.h"
+#include "cores/AudioEngine/AEFactory.h"
#include "input/KeyboardStat.h"
#include "settings/GUISettings.h"
#include "windowing/WindowingFactory.h"
@@ -206,6 +207,7 @@ void CPowerManager::OnSleep()
g_application.StopPlaying();
g_application.StopShutdownTimer();
g_application.StopScreenSaverTimer();
+ CAEFactory::Suspend();
}
void CPowerManager::OnWake()
@@ -245,6 +247,7 @@ void CPowerManager::OnWake()
g_lcd->Initialize();
#endif
+ CAEFactory::Resume();
g_application.UpdateLibraries();
g_weatherManager.Refresh();
Please sign in to comment.
Something went wrong with that request. Please try again.