Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

fixed problem with streams that update display time (DVD,BluRay), fixes smallstepback #1621

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+20 −1
Split
@@ -33,4 +33,5 @@
double pts; // pts in DVD_TIME_BASE
double dts; // dts in DVD_TIME_BASE
double duration; // duration in DVD_TIME_BASE if available
+ int time; // time as determined by input stream or -1 otherwise
} DemuxPacket;
@@ -1234,6 +1234,11 @@ void CDVDPlayer::Process()
// it's a valid data packet, reset error counter
m_errorCount = 0;
+ CDVDInputStream::IDisplayTime* pDisplayTime = dynamic_cast<CDVDInputStream::IDisplayTime*>(m_pInputStream);
+ if (pDisplayTime && pDisplayTime->GetTotalTime() > 0)
+ pPacket->time = pDisplayTime->GetTime();
+ else
+ pPacket->time = -1;
// check so that none of our streams has become invalid
if (!IsValidStream(m_CurrentAudio) && m_dvdPlayerAudio.IsStalled()) CloseAudioStream(true);
@@ -3803,10 +3808,16 @@ void CDVDPlayer::UpdatePlayState(double timeout)
SPlayerState state(m_State);
+ if( m_dvdPlayerVideo.GetCurrentPts() != DVD_NOPTS_VALUE)
+ state.dts = m_dvdPlayerVideo.GetCurrentPts();
+ else if( m_dvdPlayerAudio.GetCurrentPts() != DVD_NOPTS_VALUE)
+ state.dts = m_dvdPlayerAudio.GetCurrentPts();
+/*
if (m_CurrentVideo.dts != DVD_NOPTS_VALUE)
state.dts = m_CurrentVideo.dts;
else if(m_CurrentAudio.dts != DVD_NOPTS_VALUE)
state.dts = m_CurrentAudio.dts;
+*/
else
@elupus

elupus Oct 19, 2012

Member

This is wrong. the dts here is used for other things

@dragonflight

dragonflight Oct 19, 2012

Contributor

As far as I could tell the dts is only used for calculating state.time_offset, which it only does if it is a DVDSTREAM_TYPE_DVD (which I think is wrong as one needs the same adjustment for Blurays (?). In any case it is a diff with state.time which is now (would be) on "display time" not "read time" - but I wasn't sure which is why I left the original as a comment

state.dts = m_clock.GetClock();
@@ -3833,7 +3844,8 @@ void CDVDPlayer::UpdatePlayState(double timeout)
CDVDInputStream::IDisplayTime* pDisplayTime = dynamic_cast<CDVDInputStream::IDisplayTime*>(m_pInputStream);
if (pDisplayTime && pDisplayTime->GetTotalTime() > 0)
{
- state.time = pDisplayTime->GetTime();
+ if( m_dvdPlayerVideo.GetCurrentTime() > 0 )
+ state.time = m_dvdPlayerVideo.GetCurrentTime();
state.time_total = pDisplayTime->GetTotalTime();
}
@@ -147,6 +147,7 @@ CDVDPlayerVideo::CDVDPlayerVideo( CDVDClock* pClock
m_messageQueue.SetMaxTimeSize(8.0);
g_dvdPerformanceCounter.EnableVideoQueue(&m_messageQueue);
+ m_iCurrentTime = -1;
m_iCurrentPts = DVD_NOPTS_VALUE;
m_iDroppedFrames = 0;
m_fFrameRate = 25;
@@ -302,6 +303,7 @@ void CDVDPlayerVideo::OnStartup()
m_crop.x1 = m_crop.x2 = 0.0f;
m_crop.y1 = m_crop.y2 = 0.0f;
+ m_iCurrentTime = -1;
m_iCurrentPts = DVD_NOPTS_VALUE;
m_FlipTimeStamp = m_pClock->GetAbsoluteClock();
@@ -484,6 +486,8 @@ void CDVDPlayerVideo::Process()
DemuxPacket* pPacket = ((CDVDMsgDemuxerPacket*)pMsg)->GetPacket();
bool bPacketDrop = ((CDVDMsgDemuxerPacket*)pMsg)->GetPacketDrop();
+ if( pPacket->time != -1 )
+ m_iCurrentTime = pPacket->time;
if (m_stalled)
{
CLog::Log(LOGINFO, "CDVDPlayerVideo - Stillframe left, switching to normal playback");
@@ -88,6 +88,7 @@ class CDVDPlayerVideo : public CThread
bool InitializedOutputDevice();
+ int GetCurrentTime() { return m_iCurrentTime; }
double GetCurrentPts() { return m_iCurrentPts; }
int GetPullupCorrection() { return m_pullupCorrection.GetPatternLength(); }
@@ -124,6 +125,7 @@ class CDVDPlayerVideo : public CThread
CDVDMessageQueue m_messageQueue;
CDVDMessageQueue& m_messageParent;
+ int m_iCurrentTime; // time of last packet displayed
double m_iCurrentPts; // last pts displayed
double m_iVideoDelay;
double m_iSubtitleDelay;