From 93b35641a478a940b9b5ab86b358beaa0bbeb62d Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 25 Feb 2006 07:14:39 +0000 Subject: [PATCH] Changed audio synchronization algorithm Originally committed to SVN as r170. --- core/audio_provider.cpp | 4 ++++ core/video_display.cpp | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/audio_provider.cpp b/core/audio_provider.cpp index 79363453a..485a8de81 100644 --- a/core/audio_provider.cpp +++ b/core/audio_provider.cpp @@ -168,6 +168,10 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay * provider = new AvisynthAudioProvider(filename); #endif + #ifdef USE_LAVC + //if (!provider) provider = new LAVCAudioProvider(filename); + #endif + // No provider found if (!provider) { throw _T("Could not initialize any audio provider."); diff --git a/core/video_display.cpp b/core/video_display.cpp index 08813d04d..e67070c5c 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -885,9 +885,10 @@ void VideoDisplay::OnPlayTimer(wxTimerEvent &event) { JumpToFrame(nextFrame); // Sync audio - if (nextFrame % 25 == 0) { + if (nextFrame % 10 == 0) { __int64 audPos = audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame)); - audio->provider->SetCurrentPosition(audPos); + __int64 curPos = audio->provider->GetCurrentPosition(); + if (abs(int(audPos-curPos)) > audio->provider->GetSampleRate() / 10) audio->provider->SetCurrentPosition(audPos); } }