Skip to content
This repository
Browse code

Merge pull request #2189 from FernetMenta/pvrseek

dvdplayer: set dts after successful seek, correct time offsets
  • Loading branch information...
commit 5ee6a7ab27e7bfdaae29b9da3f2d32fa1d2c6895 2 parents 7b9ab8a + f05ffc6
Rainer Hochecker authored February 20, 2013
19  xbmc/cores/dvdplayer/DVDPlayer.cpp
@@ -2041,6 +2041,9 @@ void CDVDPlayer::HandleMessages()
2041 2041
             if(!m_pSubtitleDemuxer->SeekTime(time, msg.GetBackward()))
2042 2042
               CLog::Log(LOGDEBUG, "failed to seek subtitle demuxer: %d, success", time);
2043 2043
           }
  2044
+          // dts after successful seek
  2045
+          m_StateInput.dts = start;
  2046
+
2044 2047
           FlushBuffers(!msg.GetFlush(), start, msg.GetAccurate());
2045 2048
         }
2046 2049
         else
@@ -3228,6 +3231,11 @@ void CDVDPlayer::FlushBuffers(bool queued, double pts, bool accurate)
3228 3231
     if(pts != DVD_NOPTS_VALUE)
3229 3232
       m_clock.Discontinuity(pts);
3230 3233
     UpdatePlayState(0);
  3234
+
  3235
+    // update state, buffers are flushed and it may take some time until
  3236
+    // we get an update from players
  3237
+    CSingleLock lock(m_StateSection);
  3238
+    m_State = m_StateInput;
3231 3239
   }
3232 3240
 }
3233 3241
 
@@ -3851,8 +3859,10 @@ int CDVDPlayer::AddSubtitleFile(const std::string& filename, const std::string&
3851 3859
 
3852 3860
 void CDVDPlayer::UpdatePlayState(double timeout)
3853 3861
 {
3854  
-  if(m_StateInput.timestamp != 0
3855  
-  && m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > CDVDClock::GetAbsoluteClock())
  3862
+  if((m_StateInput.timestamp != 0)
  3863
+     && (m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > CDVDClock::GetAbsoluteClock())
  3864
+     && (m_StateInput.dts != DVD_NOPTS_VALUE)
  3865
+     && (abs(m_StateInput.dts - m_StateInput.dts_state) < DVD_MSEC_TO_TIME(timeout)))
3856 3866
     return;
3857 3867
 
3858 3868
   SPlayerState state(m_StateInput);
@@ -3861,8 +3871,6 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3861 3871
     state.dts = m_CurrentVideo.dts;
3862 3872
   else if(m_CurrentAudio.dts != DVD_NOPTS_VALUE)
3863 3873
     state.dts = m_CurrentAudio.dts;
3864  
-  else
3865  
-    state.dts = DVD_NOPTS_VALUE;
3866 3874
 
3867 3875
   if(m_pDemuxer)
3868 3876
   {
@@ -3934,7 +3942,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3934 3942
 
3935 3943
   if (state.time_src == ETIMESOURCE_CLOCK)
3936 3944
     state.time_offset = m_offset_pts;
3937  
-  else
  3945
+  else if (state.dts != DVD_NOPTS_VALUE)
3938 3946
     state.time_offset = DVD_MSEC_TO_TIME(state.time) - state.dts;
3939 3947
 
3940 3948
   if (m_CurrentAudio.id >= 0 && m_pDemuxer)
@@ -3980,6 +3988,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3980 3988
     state.cache_bytes = 0;
3981 3989
 
3982 3990
   state.timestamp = CDVDClock::GetAbsoluteClock();
  3991
+  state.dts_state = state.dts;
3983 3992
 
3984 3993
   CSingleLock lock(m_StateSection);
3985 3994
   m_StateInput = state;
2  xbmc/cores/dvdplayer/DVDPlayer.h
@@ -424,6 +424,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
424 424
       time_offset   = 0;
425 425
       time_src      = ETIMESOURCE_CLOCK;
426 426
       dts           = DVD_NOPTS_VALUE;
  427
+      dts_state     = DVD_NOPTS_VALUE;
427 428
       player_state  = "";
428 429
       chapter       = 0;
429 430
       chapter_name  = "";
@@ -449,6 +450,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
449 450
     double time_total;        // total playback time
450 451
     ETimeSource time_src;     // current time source
451 452
     double dts;               // last known dts
  453
+    double dts_state;         // dts of last update
452 454
 
453 455
     std::string player_state;  // full player state
454 456
 

0 notes on commit 5ee6a7a

Please sign in to comment.
Something went wrong with that request. Please try again.