Index: source/IAVSyncClock.h =================================================================== --- source/IAVSyncClock.h (revision 27307) +++ source/IAVSyncClock.h (working copy) @@ -41,5 +41,7 @@ virtual HRESULT STDMETHODCALLTYPE GetMaxBias(DOUBLE *bias) = 0; virtual HRESULT STDMETHODCALLTYPE GetMinBias(DOUBLE *bias) = 0; virtual HRESULT STDMETHODCALLTYPE GetClockData(CLOCKDATA *clockData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetEVRPresentationDelay(DOUBLE EVRDelay) = 0; + }; #endif // IAVSYNCCLOCK Index: source/MpAudioRenderer.cpp =================================================================== --- source/MpAudioRenderer.cpp (revision 27307) +++ source/MpAudioRenderer.cpp (working copy) @@ -699,6 +699,29 @@ } } +HRESULT CMPAudioRenderer::SetEVRPresentationDelay(DOUBLE pEVRDelay) +{ + CAutoLock cAutoLock(&m_csResampleLock); + + bool ret = S_FALSE; + + if (m_Settings.m_bUseTimeStretching) + { + Log("SetPresentationDelay: %1.10f", pEVRDelay); + + m_pClock->SetEVRDelay(pEVRDelay * 10000); // Presenter sets delay in ms + + ret = S_OK; + } + else + { + Log("SetPresentationDelay: %1.10f - failed, time stretching is disabled", pEVRDelay); + ret = S_FALSE; + } + + return ret; +} + HRESULT CMPAudioRenderer::SetBias(DOUBLE pBias) { CAutoLock cAutoLock(&m_csResampleLock); Index: source/MpAudioRenderer.h =================================================================== --- source/MpAudioRenderer.h (revision 27307) +++ source/MpAudioRenderer.h (working copy) @@ -98,6 +98,7 @@ STDMETHOD(GetMaxBias)(DOUBLE *pMaxBias); STDMETHOD(GetMinBias)(DOUBLE *pMinBias); STDMETHOD(GetClockData)(CLOCKDATA *pClockData); + STDMETHOD(SetEVRPresentationDelay)(DOUBLE pEVRDelay); HRESULT AudioClock(UINT64& pTimestamp, UINT64& pQpc); Index: source/SyncClock.cpp =================================================================== --- source/SyncClock.cpp (revision 27307) +++ source/SyncClock.cpp (working copy) @@ -33,6 +33,7 @@ m_pPrevRefClock(0), m_dAdjustment(1.0), m_dBias(1.0), + m_dEVRDelay(0.0), m_pAudioRenderer(pRenderer), m_ullStartQpcHW(0), m_ullStartTimeHW(0), @@ -50,6 +51,13 @@ { } +void CSyncClock::SetEVRDelay(double pDelay) +{ + m_SynchCorrection.SetPresenterInducedAudioDelay(pDelay); + m_dEVRDelay = pDelay; +} + + void CSyncClock::SetBias(double pBias) { m_SynchCorrection.SetBias(pBias); @@ -81,8 +89,8 @@ HRESULT CSyncClock::Reset() { CAutoLock cObjectLock(this); - m_SynchCorrection.Reset(); - m_SynchCorrection.SetBias(m_dBias); + m_SynchCorrection.Reset(m_dBias); + m_SynchCorrection.SetPresenterInducedAudioDelay(m_dEVRDelay); m_bDiscontinuity = true; return S_OK; } Index: source/SyncClock.h =================================================================== --- source/SyncClock.h (revision 27307) +++ source/SyncClock.h (working copy) @@ -33,6 +33,7 @@ void SetBias(double pBias); void SetAdjustment(double pAdjustment); void SetAudioDelay(INT64 pAudioDelay); + void SetEVRDelay(double pDelay); double Bias(); double Adjustment(); @@ -48,6 +49,7 @@ double m_dAdjustment; double m_dSuggestedAudioMultiplier; + double m_dEVRDelay; double m_dBias; double m_dSystemClockMultiplier; Index: source/SynchCorrection.cpp =================================================================== --- source/SynchCorrection.cpp (revision 27307) +++ source/SynchCorrection.cpp (working copy) @@ -55,6 +55,12 @@ m_AVTracker.Reset(); } +void SynchCorrection::Reset(double dBias) +{ + Log("SynchCorrection::Reset"); + Reset(); + m_Bias.SetAdjuster(dBias); +} double SynchCorrection::SuggestedAudioMultiplier(double sampleLength, double bias, double adjustment) { return GetRequiredAdjustment(sampleLength, m_dAVmult, bias, adjustment); @@ -151,6 +157,17 @@ return (INT64)m_dAudioDelay; } +//EVR presenter requests a delay +void SynchCorrection::SetPresenterInducedAudioDelay(INT64 delay) +{ + m_dEVRAudioDelay = (double)delay; +} + +INT64 SynchCorrection::GetPresenterInducedAudioDelay() const +{ + return (INT64)m_dEVRAudioDelay; +} + // recalculation of the delta value for the reference clock INT64 SynchCorrection::GetCorrectedTimeDelta(INT64 time) { @@ -168,7 +185,7 @@ double SynchCorrection::GetRequiredAdjustment(double sampleTime, double AVMult, double bias, double adjustment) { double ret = AVMult * bias * adjustment; - double totalAudioDrift = TotalAudioDrift(AVMult) + m_dAudioDelay + m_dBiasAdjustmentDelay; + double totalAudioDrift = TotalAudioDrift(AVMult) + m_dAudioDelay + m_dBiasAdjustmentDelay +m_dEVRAudioDelay; if (ret > 1.0 - QUALITY_BIAS_LIMIT && ret < 1.0 + QUALITY_BIAS_LIMIT) m_bQualityMode = true; Index: source/SynchCorrection.h =================================================================== --- source/SynchCorrection.h (revision 27307) +++ source/SynchCorrection.h (working copy) @@ -39,6 +39,7 @@ // Call reset when a discontinuity happens in the audio stream (drifting resets to zero etc) void Reset(); + void Reset(double dBias); // Suggested adjustment - this can be ignored if you want double SuggestedAudioMultiplier(double sampleLength, double bias, double adjustment); @@ -63,6 +64,10 @@ void SetAudioDelay(INT64 delay); INT64 GetAudioDelay() const; + // gets and sets the audio delay required by the EVR presenter in 10 shake units + void SetPresenterInducedAudioDelay(INT64 delay); + INT64 GetPresenterInducedAudioDelay() const; + // Recalculation of the delta value for the reference clock INT64 GetCorrectedTimeDelta(INT64 time); // This is used for degugging @@ -76,6 +81,7 @@ double m_dlastAdjustment; double m_dAudioDelay; + double m_dEVRAudioDelay; double m_dBiasAdjustmentDelay; int m_iBiasDir;