Skip to content

Commit

Permalink
AE: Enable SoftSuspend on Linux (Stop h0gg1ng the sound device)
Browse files Browse the repository at this point in the history
  • Loading branch information
fritsch authored and davilla committed Feb 19, 2013
1 parent d701986 commit e9e8c6c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
Expand Up @@ -1475,8 +1475,7 @@ inline void CSoftAE::ProcessSuspend()
{
bool sinkIsSuspended = false;
unsigned int curSystemClock = 0;

#if defined(TARGET_WINDOWS)
#if defined(TARGET_WINDOWS) || defined(TARGET_LINUX)
if (!m_softSuspend && m_playingStreams.empty() && m_playing_sounds.empty() &&
!g_advancedSettings.m_streamSilence)
{
Expand All @@ -1488,7 +1487,6 @@ inline void CSoftAE::ProcessSuspend()
if (m_softSuspend)
curSystemClock = XbmcThreads::SystemClockMillis();
#endif

/* idle while in Suspend() state until Resume() called */
/* idle if nothing to play and user hasn't enabled */
/* continuous streaming (silent stream) in as.xml */
Expand All @@ -1506,7 +1504,10 @@ inline void CSoftAE::ProcessSuspend()
break;
}
else
{
CLog::Log(LOGDEBUG, "Suspended the Sink");
sinkIsSuspended = true; //sink has suspended processing
}
sinkLock.Leave();
}

Expand All @@ -1525,6 +1526,7 @@ inline void CSoftAE::ProcessSuspend()
m_reOpen = !m_sink->SoftResume(); // sink returns false if it requires reinit
sinkIsSuspended = false; //sink processing data
m_softSuspend = false; //break suspend loop
CLog::Log(LOGDEBUG, "Resumed the Sink");
break;
}
}
Expand Down
21 changes: 21 additions & 0 deletions xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
Expand Up @@ -1129,6 +1129,27 @@ bool CAESinkALSA::GetELD(snd_hctl_t *hctl, int device, CAEDeviceInfo& info, bool
return true;
}

bool CAESinkALSA::SoftSuspend()
{
if(m_pcm) // it is still there
Deinitialize();

return true;
}
bool CAESinkALSA::SoftResume()
{
// reinit all the clibber
if(!m_pcm)
{
if (!snd_config)
snd_config_update();

Initialize(m_initFormat, m_initDevice);
}
//we want that AE loves us again
return false; // force reinit
}

void CAESinkALSA::sndLibErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...)
{
va_list arg;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/AudioEngine/Sinks/AESinkALSA.h
Expand Up @@ -49,6 +49,8 @@ class CAESinkALSA : public IAESink
virtual double GetCacheTotal ();
virtual unsigned int AddPackets (uint8_t *data, unsigned int frames, bool hasAudio);
virtual void Drain ();
virtual bool SoftSuspend();
virtual bool SoftResume();

static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);
private:
Expand Down

0 comments on commit e9e8c6c

Please sign in to comment.