Skip to content
This repository
Browse code

dvdplayer: ff/rw/seek was broken for inputs implementing IDisplayTime

This affected PVR with file based inputs and BluRay.
  • Loading branch information...
commit 4c90033e6987d512c1925ab6a5e31ef88bcdb28c 1 parent 5cf13fd
Joakim Plate authored January 06, 2013
14  xbmc/cores/dvdplayer/DVDPlayer.cpp
@@ -2016,6 +2016,11 @@ void CDVDPlayer::HandleMessages()
2016 2016
         double start = DVD_NOPTS_VALUE;
2017 2017
 
2018 2018
         int time = msg.GetRestore() ? (int)m_Edl.RestoreCutTime(msg.GetTime()) : msg.GetTime();
  2019
+
  2020
+        // if input streams doesn't support seektime we must convert back to clock
  2021
+        if(dynamic_cast<CDVDInputStream::ISeekTime*>(m_pInputStream) == NULL)
  2022
+          time -= m_State.time_offset;
  2023
+
2019 2024
         CLog::Log(LOGDEBUG, "demuxer seek to: %d", time);
2020 2025
         if (m_pDemuxer && m_pDemuxer->SeekTime(time, msg.GetBackward(), &start))
2021 2026
         {
@@ -3814,6 +3819,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3814 3819
 
3815 3820
     state.time       = DVD_TIME_TO_MSEC(m_clock.GetClock() + m_offset_pts);
3816 3821
     state.time_total = m_pDemuxer->GetStreamLength();
  3822
+    state.time_src   = ETIMESOURCE_CLOCK;
3817 3823
   }
3818 3824
 
3819 3825
   if(m_pInputStream)
@@ -3831,6 +3837,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3831 3837
     {
3832 3838
       state.time       = pDisplayTime->GetTime();
3833 3839
       state.time_total = pDisplayTime->GetTotalTime();
  3840
+      state.time_src   = ETIMESOURCE_INPUT;
3834 3841
     }
3835 3842
 
3836 3843
     if (dynamic_cast<CDVDInputStream::IMenus*>(m_pInputStream))
@@ -3839,6 +3846,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3839 3846
       {
3840 3847
         state.time       = XbmcThreads::SystemClockMillis() - m_dvd.iDVDStillStartTime;
3841 3848
         state.time_total = m_dvd.iDVDStillTime;
  3849
+        state.time_src   = ETIMESOURCE_MENU;
3842 3850
       }
3843 3851
     }
3844 3852
 
@@ -3864,12 +3872,14 @@ void CDVDPlayer::UpdatePlayState(double timeout)
3864 3872
   state.player_state = "";
3865 3873
   if (m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
3866 3874
   {
3867  
-    state.time_offset = DVD_MSEC_TO_TIME(state.time) - state.dts;
3868 3875
     if(!((CDVDInputStreamNavigator*)m_pInputStream)->GetNavigatorState(state.player_state))
3869 3876
       state.player_state = "";
3870 3877
   }
3871  
-  else
  3878
+
  3879
+  if (state.time_src == ETIMESOURCE_CLOCK)
3872 3880
     state.time_offset = 0;
  3881
+  else
  3882
+    state.time_offset = DVD_MSEC_TO_TIME(state.time) - state.dts;
3873 3883
 
3874 3884
   if (m_CurrentAudio.id >= 0 && m_pDemuxer)
3875 3885
   {
9  xbmc/cores/dvdplayer/DVDPlayer.h
@@ -400,6 +400,13 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
400 400
     int iSelectedAudioStream; // mpeg stream id, or -1 if disabled
401 401
   } m_dvd;
402 402
 
  403
+  enum ETimeSource
  404
+  {
  405
+    ETIMESOURCE_CLOCK,
  406
+    ETIMESOURCE_INPUT,
  407
+    ETIMESOURCE_MENU,
  408
+  };
  409
+
403 410
   struct SPlayerState
404 411
   {
405 412
     SPlayerState() { Clear(); }
@@ -409,6 +416,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
409 416
       time          = 0;
410 417
       time_total    = 0;
411 418
       time_offset   = 0;
  419
+      time_src      = ETIMESOURCE_CLOCK;
412 420
       dts           = DVD_NOPTS_VALUE;
413 421
       player_state  = "";
414 422
       chapter       = 0;
@@ -431,6 +439,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
431 439
 
432 440
     double time;              // current playback time
433 441
     double time_total;        // total playback time
  442
+    ETimeSource time_src;     // current time source
434 443
     double dts;               // last known dts
435 444
 
436 445
     std::string player_state;  // full player state

5 notes on commit 4c90033

da-anda
Collaborator

did a quick test on how PVR behaves after this. Jump forward/back still don't work (which was expected).

I'm not entirely sure about FFW/FRW, which AFAIK is atm the only reliable way to "skip" in the timeshift buffer of backends using XBMCs demuxer. It's kinda still working, but I think not as reliable as before. But I can't really tell because I'm not using PVR in XBMC due to missing stepforward/-back which is essential for me. So I only did a quick test, and sometimes it worked, sometimes it was caught in some sort of loop. The loop looked like this: I started ffw, and at a fixed position it jumped to the beginning of the timeshift buffer and started all over again. The jump occured somewhere in the middle of the buffer - so for sure not at the end. Will compare to earlier behavior later and report again if the issue wasn't there.

Joakim Plate
Collaborator
da-anda
Collaborator

ffwd/frwd work fine for blurays, but are for sure broken now for PVR addons using XBMCs demuxer. At least it didn't work at all for me now (XBMC always tried to ffwd/frwd at the end position of the buffer). Also step forward/back now jumped to the end of the buffer instead of the beginning like it did a few hours ago with the same XBMC version/install which is kinda odd. It probably depends on how far the TV show already progressed when you start watching it - that's at least the only explanation I can think of atm.

Lars Op den Kamp
Collaborator

@da-anda which backend? and there is at least one bug in that code when no epg tag is present for the channel or when the epg tag changed.

Lars Op den Kamp
Collaborator

oh nvm, you're talking about xbmc's demuxer, not one in the add-on

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