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 31, 2024
1 parent 11b69d1 commit d301796
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/stream/FFmpegStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,24 @@ bool FFmpegStream::SeekTime(double time, bool backwards, double* startpts)
}
}

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
Expand Down

0 comments on commit d301796

Please sign in to comment.