diff options
author | huceke <ebsi4711@gmail.com> | 2013-01-17 02:49:25 -0800 |
---|---|---|
committer | huceke <ebsi4711@gmail.com> | 2013-01-17 02:49:25 -0800 |
commit | c5d4690ed8e1dc2ee643bfc0d4ef60e43ad66b34 (patch) | |
tree | 25508a17ebfa2851b5b7783f31dcd74406c13b00 | |
parent | 7d4b8a81b86c88078ded69acebc7cf9b04870a47 (diff) | |
parent | c570270e2cbfb8d276eb8d76e14d78965246ad00 (diff) |
Merge pull request #2075 from Memphiz/streamsilence
[AE/CA] - implement the advancedsetting for streamsilence
-rw-r--r-- | xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp | 40 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h | 2 |
2 files changed, 38 insertions, 4 deletions
diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp index c6e030979d..68dd891158 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp @@ -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); diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h index 5034b68a3f..bdb9ccb219 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h @@ -172,4 +172,6 @@ private: int m_soundMode; bool m_streamsPlaying; bool m_isSuspended; + bool m_softSuspend; + unsigned int m_softSuspendTimer; }; |