If Ctrl is held when video playback is started, no audio resync is attempted during that playback.

Originally committed to SVN as r1201.
This commit is contained in:
Niels Martin Hansen 2007-06-02 13:48:36 +00:00
parent 59aad1f044
commit 5a4e03312a
3 changed files with 12 additions and 4 deletions

View File

@ -196,14 +196,18 @@ END_EVENT_TABLE()
//////////////
// Play video
void VideoBox::OnVideoPlay(wxCommandEvent &event) {
VideoContext::Get()->Play();
VideoContext *ctx = VideoContext::Get();
ctx->EnableAudioSync(wxGetMouseState().ControlDown() == false);
ctx->Play();
}
///////////////////
// Play video line
void VideoBox::OnVideoPlayLine(wxCommandEvent &event) {
VideoContext::Get()->PlayLine();
VideoContext *ctx = VideoContext::Get();
ctx->EnableAudioSync(wxGetMouseState().ControlDown() == false);
ctx->PlayLine();
}

View File

@ -114,6 +114,7 @@ VideoContext::VideoContext() {
arValue = 1.0;
isPlaying = false;
nextFrame = -1;
keepAudioSync = true;
// Threads
threaded = Options.AsBool(_T("Threaded Video"));
@ -723,7 +724,7 @@ void VideoContext::OnPlayTimer(wxTimerEvent &event) {
if (nextFrame == frame_n) return;
// Next frame is before or over 2 frames ahead, so force audio resync
if (nextFrame < frame_n || nextFrame > frame_n + 2) audio->player->SetCurrentPosition(audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame)));
if (keepAudioSync && (nextFrame < frame_n || nextFrame > frame_n + 2)) audio->player->SetCurrentPosition(audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame)));
// Jump to next frame
playNextFrame = nextFrame;
@ -731,7 +732,7 @@ void VideoContext::OnPlayTimer(wxTimerEvent &event) {
JumpToFrame(nextFrame);
// Sync audio
if (nextFrame % 10 == 0) {
if (keepAudioSync && nextFrame % 10 == 0) {
__int64 audPos = audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame));
__int64 curPos = audio->player->GetCurrentPosition();
int delta = int(audPos-curPos);

View File

@ -103,6 +103,7 @@ private:
bool loaded;
bool isInverted;
bool isPlaying;
bool keepAudioSync;
float texW,texH;
int w,h;
@ -146,6 +147,8 @@ public:
bool IsPlaying() { return isPlaying; }
bool IsInverted() { return isInverted; }
void EnableAudioSync(bool sync = true) { keepAudioSync = sync; }
int GetWidth() { return w; }
int GetHeight() { return h; }
int GetLength() { return length; }