diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2015-11-12 20:26:41 +0100 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2015-11-12 20:26:41 +0100 |
commit | 4bd354cbc175d6485e704243a177b2e714943fb1 (patch) | |
tree | bc5fceb2f086898dfa598525c9b0d6ffbe06d7ff | |
parent | a3298f3ef235a2662a686cd888b4caab61f102b8 (diff) |
AE: fix GetDelay - only apply time correction to sink delay
-rw-r--r-- | xbmc/cores/AudioEngine/Utils/AEUtil.cpp | 19 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Utils/AEUtil.h | 6 |
2 files changed, 14 insertions, 11 deletions
diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.cpp b/xbmc/cores/AudioEngine/Utils/AEUtil.cpp index 6d6b0e19ca..90f6c44431 100644 --- a/xbmc/cores/AudioEngine/Utils/AEUtil.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEUtil.cpp @@ -38,21 +38,22 @@ unsigned int CAEUtil::m_seed = (unsigned int)(CurrentHostCounter() / 1000.0f); MEMALIGN(16, __m128i CAEUtil::m_sseSeed) = _mm_set_epi32(CAEUtil::m_seed, CAEUtil::m_seed+1, CAEUtil::m_seed, CAEUtil::m_seed+1); #endif -void AEDelayStatus::SetDelay(double d) +void AEDelayStatus::SetDelay(double d) { delay = d; - tick = CurrentHostCounter(); + maxcorrection = d; + tick = CurrentHostCounter(); } double AEDelayStatus::GetDelay() { - double d = delay; - if(tick) - d -= (double)(CurrentHostCounter() - tick) / CurrentHostFrequency(); - if(d < 0) - return 0.0; - else - return d; + double d = 0; + if (tick) + d = (double)(CurrentHostCounter() - tick) / CurrentHostFrequency(); + if (d > maxcorrection) + d = maxcorrection; + + return delay - d; } CAEChannelInfo CAEUtil::GuessChLayout(const unsigned int channels) diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.h b/xbmc/cores/AudioEngine/Utils/AEUtil.h index edc920ee64..56c0a1f038 100644 --- a/xbmc/cores/AudioEngine/Utils/AEUtil.h +++ b/xbmc/cores/AudioEngine/Utils/AEUtil.h @@ -64,14 +64,16 @@ struct AEDelayStatus { AEDelayStatus() : delay(0.0) + , maxcorrection(0.0) , tick(0) {} void SetDelay(double d); double GetDelay(); - double delay; /*!< delay in sink currently */ - int64_t tick; /*!< timestamp when delay was calculated */ + double delay; // delay in sink currently + double maxcorrection; // time correction must not be greater than sink delay + int64_t tick; // timestamp when delay was calculated }; /** |