// Set position just to keep mActualPosition and mLastActualRateTimeStamp reasonable // this- > Cue(position, commandTimeStamp); // Clear mCueHint to force a cue before any new rates are sent mCueHint = 0; mCuePosition = position; // Otherwise, if we're not cueing, set the transport rate else if (TimeStamp) (commandTimeStamp + (TimeStamp)newFilterPoint.mRate.mSample) > = mCueTimeStamp) Bool32 lock mUnityRateTimer = = forwardSyncLockDelay mUnityRateTimer = = reverseSyncLockDelay & & SY::abs(newRate) = = 1.0; if (newRate ! = mLastActualRate | lock ! = mLastActualLock) thls- > SetTransportRate(newRate, rateTlmeStamp, lock); mCueTlmeStamp = rateTimeStamp; if (mCueHint ! = CUEHINT~BIDIRECTIONAL) { Int32 cueDelay = this- > GetCueDelay( ); if (position > = mCuePosition + CueDelay) mCueHint ! = CUEHINT~BACKWARD; else if (position mCueHint ! = CUEHINT~FORWARD; } } } void SyNewRateControl::SetRate(IEEE32 rate, TimeStamp timeStamp, Bool32 lock) { ::SyEnterCriticalSection( & mTransportCS); mActualPosition += mLastActualRate * (timeStamp mLastActualRateTimeStamp); //SYTRACE( T("SR MAP %f\n"), (float) mActualPosition); mLastActualRate = rate mLastActualRateTimeStamp = tiemStamp; mLastActualLock = lock; ::SyLeaveCriticalSection( & mTransportCS); #ifdef TRACE TimeStamp cur = tis- > GetReferenceTime( ); SYRELTRACE(~T("SetRate(%f, %lu, %d), cur=%lu, delta=%ld\n"), rate, timeStamp, lock, cur, timeStamp - cur); #endif void SyNewRateControl::Cue(TimeCode time, TimeStamp timeStamp) ::SyEnterCriticalSection( & mTransportCS); mActualPosition = time; //SYTRACES T("Cu MAP: %F\n"), (float) mActualPosition); mLastActualRateTimeStamp = timeStamp; ::SyLeaveCriticalSection( & mTransportCS); #ifdef TRACE TimeStamp cur = this - > GetReferenceTime SYRELTRACE(~T("Cue(%I64d, %lu), cur=%lu, delta=%ld\n"), time, timeStamp, cur, timeStamp - cur); #endif void SyNewRateControl::UpdateForwardSyncLockDelay(UInt32 forwardSyncLockDelay) if (forwardSyncLockDelay = = INFINITE) mForwardSyncLockDelay = INFINITE SYNCLOCK DELAY; else UInt32 SyncLockDelay = (forwardSyncLockDelay (kFrameSamplePeriod * kDecimate > > 1)) / (kFrameSamplePeriod * kDecimate); mForwardSyncLockDelay = syncLockDelay > 0x7FFF ? 0x7FFF : syncLockDelay; #ifdef TRACE SYRELTRACE(~T("mForwardSyncLockDelay set to %d\n"), mForwardSyncLockDelay); #endif void SyNewRateControl::UpdateReverseSyncLockDelay(UInt32 reverseSyncLockDelay) if (reverseSyncLockDelay = = INFINITE) mReverseSyncLockDelay = INFINITE~SYNCLOCK~DELAY; else UInt32 syncLockDelay = (reverseSyncLockDelay + (kFrameSamplePeriod * kDecimat > > 1)) / (kFrameSamplePeriod * kDecimate); mReverseSyncLockDelay = synctockoelay > 0x7FFF ? -0x7FFF: -syncLockDelay; } #ifdef ~TRACE SYRELTRACE(~T(""mReverseSyncLockDelay set to %d\n"), mReverseSyncLokDelay); #endif ) void SyNewRateControl::UpdateForwardFilterLength(UInt32 minForwardFilterLength) ( UInt32 twoToTheMlnFllterDepthMinusTwo = (mFrameUpdatePeriod + minForwardFilterLength) / kFrameSamplePeriod; for UIntl6 minForwardFilterDepth = 1; // For thread protection, use a local variable while calculating filter depth twoToTheMinFilterDepthMinusTwo ! = 0 & & minForwardFilteroepth kMaxFilterDepth; twoToTheMinFilterDepthMinusTwo = 1, mlnForwardFilterDepth++ mMinForwardFilterDepth = minForwardFilterDepth > kMaxFilterDepth ? kMaxFilterDepth . minForwardFilterDepth; #ifdef TRACE SYRELTRACE UInt32 twoToTheMinFilterDepthMinusTwo = (mFrameUpdatePeriod + minReverseFilterLength) / kFrameSamplePeriod; for UIntl6 minReverseFllterDepth = 1; // For thread protection, use a local variable while calculating filter depth twoToTheMinFilterDepthMinusTwo ! = 0 & & minReverseFilterDepth kMaxFilterDepth ; twoToTheMinFilterDepthMinusTwo = 1, minReverseFilterDepth++ mMinReverseFilterDepth - minReverseFilterDepth > kMaxFilterDepth ? kMaxFilterDepth : min ReverseFilterDepth; #ifdef TRACE SYRELTRACE(~T("minReverseFilterDepht set to %d\n"), minReverseFilterDepth) #endif SyNewRateControl::FilterPipe::FilterPipe(UInt32 length) SySigPipe length, new SyNullMutex, new SyNullMutex, new SySemaphoreSemaphore(length, length), new SySemaphoreSemaphore(0, length) SyNewRateControl::FilterPipe::~FilterPipe(void) { delete this- > EmptySempahore(); delete this- > FullSemaphore(); delete this- > SinkMutes(); delete this- > SourceMutes(); }