diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2015-04-14 14:39:28 +0200 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2015-04-14 14:39:28 +0200 |
commit | 6def365ddeb10fa9ef0b50df2862c0001b794932 (patch) | |
tree | 2a817c10a2d7381faa5e347cbc53002bccc1fc7b | |
parent | 59a0383151cca045bf77a65f64862aeff5cdee57 (diff) | |
parent | 095d6a8f0f34658d86f935cb0b737cb7bc791a13 (diff) |
Merge pull request #6945 from FernetMenta/sync3
dvdplayer: audio sync fixes
-rw-r--r-- | xbmc/cores/dvdplayer/DVDAudio.cpp | 14 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDPlayerAudio.cpp | 9 |
2 files changed, 19 insertions, 4 deletions
diff --git a/xbmc/cores/dvdplayer/DVDAudio.cpp b/xbmc/cores/dvdplayer/DVDAudio.cpp index a2b1325e05..d1601b1279 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDAudio.cpp @@ -276,5 +276,17 @@ double CDVDAudio::GetPlayingPts() if (m_playingPts == DVD_NOPTS_VALUE) return 0.0; - return m_playingPts + CDVDClock::GetAbsoluteClock() - m_timeOfPts; + double now = CDVDClock::GetAbsoluteClock(); + double diff = now - m_timeOfPts; + double cache = GetCacheTime(); + double played = 0.0; + + if (diff < cache) + played = diff; + else + played = cache; + + m_timeOfPts = now; + m_playingPts += played; + return m_playingPts; } diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index 74df969217..a345a880ea 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -372,6 +372,7 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe) if (pMsgGeneralResync->m_clock) m_pClock->Discontinuity(m_dvdAudio.GetPlayingPts()); m_syncclock = true; + m_errors.Flush(); } else if (pMsg->IsType(CDVDMsg::GENERAL_RESET)) { @@ -439,6 +440,7 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe) { m_dvdAudio.Resume(); m_syncclock = true; + m_errors.Flush(); } } else @@ -548,7 +550,7 @@ void CDVDPlayerAudio::Process() if( audioframe.nb_frames == 0 ) continue; - packetadded = true; + packetadded = false; // we have succesfully decoded an audio frame, setup renderer to match if (!m_dvdAudio.IsValidFormat(audioframe)) @@ -598,10 +600,11 @@ void CDVDPlayerAudio::Process() } // signal to our parent that we have initialized - if(m_started == false && packetadded) + if(m_started == false) { m_started = true; m_messageParent.Put(new CDVDMsgInt(CDVDMsg::PLAYER_STARTED, DVDPLAYER_AUDIO)); + m_errors.Flush(); } if( m_dvdAudio.GetPlayingPts() == DVD_NOPTS_VALUE ) @@ -662,7 +665,7 @@ void CDVDPlayerAudio::HandleSyncError(double duration) // as long as we are in sync mode, don't calculate the average // error because drop/dupe changes the value - if (m_syncclock && error > threshold1) + if (m_syncclock && fabs(error) > threshold1) { m_errors.Flush(500); m_integral = 0.0; |