Skip to content

Commit

Permalink
VideoPlayer: fix a/v sync - if audio and video needs sync, this has prio
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jan 18, 2016
1 parent ade4ef2 commit 453d132
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ void CVideoPlayer::HandlePlaySpeed()
}

// sync streams to clock
if ((m_CurrentVideo.syncState == IDVDStreamPlayer::SYNC_WAITSYNC) ||
if ((m_CurrentVideo.syncState == IDVDStreamPlayer::SYNC_WAITSYNC) &&
(m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC))
{
unsigned int threshold = 20;
Expand All @@ -1987,19 +1987,7 @@ void CVideoPlayer::HandlePlaySpeed()
bool audio = m_CurrentAudio.id < 0 || (m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC) ||
(m_CurrentAudio.packets == 0 && m_CurrentVideo.packets > threshold);

if (m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC &&
m_CurrentAudio.avsync == CCurrentStream::AV_SYNC_CONT)
{
m_CurrentAudio.syncState = IDVDStreamPlayer::SYNC_INSYNC;
m_VideoPlayerAudio->SendMessage(new CDVDMsgDouble(CDVDMsg::GENERAL_RESYNC, m_clock.GetClock()), 1);
}
else if (m_CurrentVideo.syncState == IDVDStreamPlayer::SYNC_WAITSYNC &&
m_CurrentVideo.avsync == CCurrentStream::AV_SYNC_CONT)
{
m_CurrentVideo.syncState = IDVDStreamPlayer::SYNC_INSYNC;
m_VideoPlayerVideo->SendMessage(new CDVDMsgDouble(CDVDMsg::GENERAL_RESYNC, m_clock.GetClock()), 1);
}
else if (video && audio)
if (video && audio)
{
double clock = 0;
if (m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC)
Expand Down Expand Up @@ -2041,6 +2029,22 @@ void CVideoPlayer::HandlePlaySpeed()
m_syncTimer.Set(3000);
}
}
else if ((m_CurrentVideo.syncState == IDVDStreamPlayer::SYNC_WAITSYNC) ||
(m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC))
{
if (m_CurrentAudio.syncState == IDVDStreamPlayer::SYNC_WAITSYNC &&
m_CurrentAudio.avsync == CCurrentStream::AV_SYNC_CONT)
{
m_CurrentAudio.syncState = IDVDStreamPlayer::SYNC_INSYNC;
m_VideoPlayerAudio->SendMessage(new CDVDMsgDouble(CDVDMsg::GENERAL_RESYNC, m_clock.GetClock()), 1);
}
else if (m_CurrentVideo.syncState == IDVDStreamPlayer::SYNC_WAITSYNC &&
m_CurrentVideo.avsync == CCurrentStream::AV_SYNC_CONT)
{
m_CurrentVideo.syncState = IDVDStreamPlayer::SYNC_INSYNC;
m_VideoPlayerVideo->SendMessage(new CDVDMsgDouble(CDVDMsg::GENERAL_RESYNC, m_clock.GetClock()), 1);
}
}

// handle ff/rw
if(m_playSpeed != DVD_PLAYSPEED_NORMAL && m_playSpeed != DVD_PLAYSPEED_PAUSE)
Expand Down

0 comments on commit 453d132

Please sign in to comment.