Skip to content
This repository
Browse code

Merge pull request #2075 from Memphiz/streamsilence

[AE/CA] - implement the advancedsetting for streamsilence
  • Loading branch information...
commit c5d4690ed8e1dc2ee643bfc0d4ef60e43ad66b34 2 parents 7d4b8a8 + c570270
huceke authored January 17, 2013
40  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp
@@ -33,6 +33,7 @@
33 33
 #include "utils/log.h"
34 34
 #include "utils/TimeUtils.h"
35 35
 #include "utils/MathUtils.h"
  36
+#include "threads/SystemClock.h"
36 37
 
37 38
 #define DELAY_FRAME_TIME  20
38 39
 #define BUFFERSIZE        16416
@@ -50,7 +51,9 @@ CCoreAudioAE::CCoreAudioAE() :
50 51
   m_muted              (false         ),
51 52
   m_soundMode          (AE_SOUND_OFF  ),
52 53
   m_streamsPlaying     (false         ),
53  
-  m_isSuspended        (false         )
  54
+  m_isSuspended        (false         ),
  55
+  m_softSuspend        (false         ),
  56
+  m_softSuspendTimer   (0             )
54 57
 {
55 58
   HAL = new CCoreAudioAEHAL;
56 59
 }
@@ -428,7 +431,7 @@ IAEStream* CCoreAudioAE::MakeStream(enum AEDataFormat dataFormat,
428 431
 {
429 432
   // if we are suspended we don't
430 433
   // want anyone to mess with us
431  
-  if (m_isSuspended)
  434
+  if (m_isSuspended && !m_softSuspend)
432 435
     return NULL;
433 436
 
434 437
   CAEChannelInfo channelInfo(channelLayout);
@@ -510,7 +513,7 @@ IAEStream* CCoreAudioAE::FreeStream(IAEStream *stream)
510 513
 
511 514
 void CCoreAudioAE::PlaySound(IAESound *sound)
512 515
 {
513  
-  if (m_soundMode == AE_SOUND_OFF || (m_soundMode == AE_SOUND_IDLE && m_streamsPlaying) || m_isSuspended)
  516
+  if (m_soundMode == AE_SOUND_OFF || (m_soundMode == AE_SOUND_IDLE && m_streamsPlaying) || (m_isSuspended && !m_softSuspend))
514 517
     return;
515 518
 
516 519
   float *samples = ((CCoreAudioAESound*)sound)->GetSamples();
@@ -632,11 +635,40 @@ void CCoreAudioAE::MixSounds(float *buffer, unsigned int samples)
632 635
 
633 636
 void CCoreAudioAE::GarbageCollect()
634 637
 {
  638
+  if (g_advancedSettings.m_streamSilence)
  639
+    return;
  640
+  
  641
+  if (!m_streamsPlaying && m_playing_sounds.empty())
  642
+  {
  643
+    if (!m_softSuspend)
  644
+    {
  645
+      m_softSuspend = true;
  646
+      m_softSuspendTimer = XbmcThreads::SystemClockMillis() + 10000; //10.0 second delay for softSuspend
  647
+    }
  648
+  }
  649
+  else
  650
+  {
  651
+    if (m_isSuspended)
  652
+    {
  653
+      CLog::Log(LOGDEBUG, "CCoreAudioAE::GarbageCollect - Acquire CA HAL.");
  654
+      Start();
  655
+      m_isSuspended = false;
  656
+    }
  657
+    m_softSuspend = false;
  658
+  }
  659
+  
  660
+  unsigned int curSystemClock = XbmcThreads::SystemClockMillis();
  661
+  if (!m_isSuspended && m_softSuspend && curSystemClock > m_softSuspendTimer)
  662
+  {
  663
+    Stop();
  664
+    m_isSuspended = true;
  665
+    CLog::Log(LOGDEBUG, "CCoreAudioAE::GarbageCollect - Release CA HAL.");
  666
+  }
635 667
 }
636 668
 
637 669
 void CCoreAudioAE::EnumerateOutputDevices(AEDeviceList &devices, bool passthrough)
638 670
 {
639  
-  if (m_isSuspended)
  671
+  if (m_isSuspended && !m_softSuspend)
640 672
     return;
641 673
 
642 674
   HAL->EnumerateOutputDevices(devices, passthrough);
2  xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.h
@@ -172,4 +172,6 @@ class CCoreAudioAE : public IAE, public ICoreAudioSource
172 172
   int               m_soundMode;
173 173
   bool              m_streamsPlaying;
174 174
   bool              m_isSuspended;
  175
+  bool              m_softSuspend;
  176
+  unsigned int      m_softSuspendTimer;
175 177
 };

0 notes on commit c5d4690

Please sign in to comment.
Something went wrong with that request. Please try again.