Skip to content

Commit

Permalink
CDVDDemuxFFmpeg: After seek ensure a valid timestamp is read to suppo…
Browse files Browse the repository at this point in the history
…rt chapters

m_currentPts is not currently set after a seek until a suitable packet is read.

That may cause issues with chapters, so make sure m_currentPts is valid
immediately after a seek.
  • Loading branch information
phunkyfish committed Jan 28, 2024
1 parent 64c5bae commit fef0f52
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/stream/FFmpegStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,29 @@ bool FFmpegStream::SeekTime(double time, bool backwards, double* startpts)
}
}

Log(LOGLEVEL_DEBUG, "%s - seek to time:%.2f ret:%d hitEnd:%d", __FUNCTION__, time, ret,
hitEnd);
if (ret >= 0)
{
kodi::tools::CEndTime timer(1000);
while (m_currentPts == STREAM_NOPTS_VALUE && !timer.IsTimePast())
{
m_pkt.result = -1;
av_packet_unref(&m_pkt.pkt);

DEMUX_PACKET* pkt = DemuxRead();
if (!pkt)
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
continue;
}
m_demuxPacketManager->FreeDemuxPacketFromInputStreamAPI(pkt);
}
}

if (m_currentPts == STREAM_NOPTS_VALUE)
Log(LOGLEVEL_DEBUG, "%s - unknown position after seek", __FUNCTION__);
else
Log(LOGLEVEL_DEBUG, "%s - seek ended up on time %d", __FUNCTION__,
(int)(m_currentPts / DVD_TIME_BASE * 1000));

// in this case the start time is requested time
if (startpts)
Expand Down

0 comments on commit fef0f52

Please sign in to comment.