diff options
Diffstat (limited to 'libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp')
-rw-r--r-- | libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp index 7c57a81ede..85dad84914 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/Utility/AUTimestampGenerator.cpp @@ -2,14 +2,14 @@ File: AUTimestampGenerator.cpp Abstract: AUTimestampGenerator.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include "AUTimestampGenerator.h" #include "CAMath.h" @@ -68,12 +68,12 @@ void AUTimestampGenerator::AddOutputTime(const AudioTimeStamp &inTimeStamp, Floa if (mState.mBypassed) return; - + if (mState.mHostTimeDiscontinuityCorrection && !(mState.mCurrentOutputTime.mFlags & kAudioTimeStampHostTimeValid) && (mState.mLastOutputTime.mFlags & kAudioTimeStampHostTimeValid)) { // no host time here but we had one last time, interpolate one double rateScalar = (mState.mCurrentOutputTime.mFlags & kAudioTimeStampRateScalarValid) ? mState.mCurrentOutputTime.mRateScalar : 1.0; Float64 deltaSamples = mState.mCurrentOutputTime.mSampleTime - mState.mLastOutputTime.mSampleTime; - mState.mCurrentOutputTime.mHostTime = mState.mLastOutputTime.mHostTime + + mState.mCurrentOutputTime.mHostTime = mState.mLastOutputTime.mHostTime + UInt64(CAHostTimeBase::GetFrequency() * deltaSamples * rateScalar / outputSampleRate); mState.mCurrentOutputTime.mFlags |= kAudioTimeStampHostTimeValid; #if DEBUG @@ -90,7 +90,7 @@ void AUTimestampGenerator::AddOutputTime(const AudioTimeStamp &inTimeStamp, Floa mState.mCurrentOutputTime.mFlags |= kAudioTimeStampRateScalarValid; } } - + if (mFirstTime) { mFirstTime = false; mState.mDiscontinuous = false; @@ -120,16 +120,16 @@ const AudioTimeStamp & AUTimestampGenerator::GenerateInputTime(Float64 framesToA return mState.mCurrentOutputTime; double inputSampleTime; - + mState.mCurrentInputTime.mFlags = kAudioTimeStampSampleTimeValid; double rateScalar = 1.0; - + // propagate rate scalar if (mState.mCurrentOutputTime.mFlags & kAudioTimeStampRateScalarValid) { mState.mCurrentInputTime.mFlags |= kAudioTimeStampRateScalarValid; mState.mCurrentInputTime.mRateScalar = rateScalar = mState.mCurrentOutputTime.mRateScalar; } - + // propagate host time and sample time if (mState.mCurrentOutputTime.mFlags & kAudioTimeStampHostTimeValid) { mState.mCurrentInputTime.mFlags |= kAudioTimeStampHostTimeValid; @@ -142,7 +142,7 @@ const AudioTimeStamp & AUTimestampGenerator::GenerateInputTime(Float64 framesToA mState.mCurrentInputTime.mHostTime = mState.mCurrentOutputTime.mHostTime; } if (mState.mHostTimeDiscontinuityCorrection && mState.mDiscontinuous && (mState.mLastOutputTime.mFlags & kAudioTimeStampHostTimeValid)) { - // we had a discontinuous output time, need to resync by interpolating + // we had a discontinuous output time, need to resync by interpolating // a sample time that is appropriate to the host time UInt64 deltaHostTime = mState.mCurrentOutputTime.mHostTime - mState.mLastOutputTime.mHostTime; double deltaSeconds = double(deltaHostTime) * CAHostTimeBase::GetInverseFrequency(); @@ -168,28 +168,28 @@ const AudioTimeStamp & AUTimestampGenerator::GenerateInputTime(Float64 framesToA // we had a discontinuous output time, need to resync by propagating the // detected discontinuity, taking the rate scalar adjustment into account inputSampleTime += floor(mState.mDiscontinuityDeltaSamples / mState.mRateScalarAdj + 0.5); - + #if DEBUG if (mVerbosity > 1) printf("%-20.20s: adjusted input time: %.0f -> %.0f (SR=%.3f, rs=%.3f, delta=%.0f)\n", mDebugName, mState.mNextInputSampleTime, inputSampleTime, inputSampleRate, mState.mRateScalarAdj, mState.mDiscontinuityDeltaSamples); #endif - + mState.mDiscontinuityDeltaSamples = 0.; } - - + + // propagate word clock if (mState.mCurrentOutputTime.mFlags & kAudioTimeStampWordClockTimeValid) { mState.mCurrentInputTime.mFlags |= kAudioTimeStampWordClockTimeValid; mState.mCurrentInputTime.mWordClockTime = mState.mCurrentOutputTime.mWordClockTime; } - + // propagate SMPTE time if (mState.mCurrentOutputTime.mFlags & kAudioTimeStampSMPTETimeValid) { mState.mCurrentInputTime.mFlags |= kAudioTimeStampSMPTETimeValid; mState.mCurrentInputTime.mSMPTETime = mState.mCurrentOutputTime.mSMPTETime; } - + // store the input sample time and expected next input time mState.mCurrentInputTime.mSampleTime = inputSampleTime; mState.mNextInputSampleTime = inputSampleTime + framesToAdvance; |