Skip to content

Commit

Permalink
Merge pull request #2061 from davilla/vamp-fixes
Browse files Browse the repository at this point in the history
VampireAE fixes, mmm'kay
  • Loading branch information
davilla committed Jan 18, 2013
2 parents a689ba1 + 34b240e commit 637279d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
31 changes: 26 additions & 5 deletions xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,11 @@ double CSoftAE::GetCacheTotal()

bool CSoftAE::IsSuspended()
{
#if defined(TARGET_WINDOWS)
return m_isSuspended;
#else
return false;
#endif
}

float CSoftAE::GetVolume()
Expand Down Expand Up @@ -968,24 +972,27 @@ 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)
{
CSoftAEStream *stream = *itt;
stream->Flush();
}
#endif

return true;
}

bool CSoftAE::Resume()
{
CLog::Log(LOGDEBUG, "CSoftAE::Resume - Resuming AE processing");
#if defined(TARGET_WINDOWS)
m_isSuspended = false;
m_reOpen = true;
#endif

return true;
}
Expand Down Expand Up @@ -1021,7 +1028,7 @@ void CSoftAE::Run()
restart = true;
}

#if !defined(TARGET_ANDROID)
#if defined(TARGET_WINDOWS)
/* Handle idle or forced suspend */
ProcessSuspend();
#endif
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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);
}

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 */
Expand Down
3 changes: 3 additions & 0 deletions xbmc/powermanagement/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -206,6 +207,7 @@ void CPowerManager::OnSleep()
g_application.StopPlaying();
g_application.StopShutdownTimer();
g_application.StopScreenSaverTimer();
CAEFactory::Suspend();
}

void CPowerManager::OnWake()
Expand Down Expand Up @@ -245,6 +247,7 @@ void CPowerManager::OnWake()
g_lcd->Initialize();
#endif

CAEFactory::Resume();
g_application.UpdateLibraries();
g_weatherManager.Refresh();

Expand Down

0 comments on commit 637279d

Please sign in to comment.