Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2075 from Memphiz/streamsilence

[AE/CA] - implement the advancedsetting for streamsilence
  • Loading branch information...
commit c5d4690ed8e1dc2ee643bfc0d4ef60e43ad66b34 2 parents 7d4b8a8 + c570270
huceke huceke authored
40 xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp
View
@@ -33,6 +33,7 @@
#include "utils/log.h"
#include "utils/TimeUtils.h"
#include "utils/MathUtils.h"
+#include "threads/SystemClock.h"
#define DELAY_FRAME_TIME 20
#define BUFFERSIZE 16416
@@ -50,7 +51,9 @@ CCoreAudioAE::CCoreAudioAE() :
m_muted (false ),
m_soundMode (AE_SOUND_OFF ),
m_streamsPlaying (false ),
- m_isSuspended (false )
+ m_isSuspended (false ),
+ m_softSuspend (false ),
+ m_softSuspendTimer (0 )
{
HAL = new CCoreAudioAEHAL;
}
@@ -428,7 +431,7 @@ IAEStream* CCoreAudioAE::MakeStream(enum AEDataFormat dataFormat,
{
// if we are suspended we don't
// want anyone to mess with us
- if (m_isSuspended)
+ if (m_isSuspended && !m_softSuspend)
return NULL;
CAEChannelInfo channelInfo(channelLayout);
@@ -510,7 +513,7 @@ IAEStream* CCoreAudioAE::FreeStream(IAEStream *stream)
void CCoreAudioAE::PlaySound(IAESound *sound)
{
- if (m_soundMode == AE_SOUND_OFF || (m_soundMode == AE_SOUND_IDLE && m_streamsPlaying) || m_isSuspended)
+ if (m_soundMode == AE_SOUND_OFF || (m_soundMode == AE_SOUND_IDLE && m_streamsPlaying) || (m_isSuspended && !m_softSuspend))
return;
float *samples = ((CCoreAudioAESound*)sound)->GetSamples();
@@ -632,11 +635,40 @@ void CCoreAudioAE::MixSounds(float *buffer, unsigned int samples)
void CCoreAudioAE::GarbageCollect()
{
+ if (g_advancedSettings.m_streamSilence)
+ return;
+
+ if (!m_streamsPlaying && m_playing_sounds.empty())
+ {
+ if (!m_softSuspend)
+ {
+ m_softSuspend = true;
+ m_softSuspendTimer = XbmcThreads::SystemClockMillis() + 10000; //10.0 second delay for softSuspend
+ }
+ }
+ else
+ {
+ if (m_isSuspended)
+ {
+ CLog::Log(LOGDEBUG, "CCoreAudioAE::GarbageCollect - Acquire CA HAL.");
+ Start();
+ m_isSuspended = false;
+ }
+ m_softSuspend = false;
+ }
+
+ unsigned int curSystemClock = XbmcThreads::SystemClockMillis();
+ if (!m_isSuspended && m_softSuspend && curSystemClock > m_softSuspendTimer)
+ {
+ Stop();
+ m_isSuspended = true;
+ CLog::Log(LOGDEBUG, "CCoreAudioAE::GarbageCollect - Release CA HAL.");
+ }
}
void CCoreAudioAE::EnumerateOutputDevices(AEDeviceList &devices, bool passthrough)
{
- if (m_isSuspended)
+ if (m_isSuspended && !m_softSuspend)
return;
HAL->EnumerateOutputDevices(devices, passthrough);
2  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h
View
@@ -172,4 +172,6 @@ class CCoreAudioAE : public IAE, public ICoreAudioSource
int m_soundMode;
bool m_streamsPlaying;
bool m_isSuspended;
+ bool m_softSuspend;
+ unsigned int m_softSuspendTimer;
};
Please sign in to comment.
Something went wrong with that request. Please try again.