Fix VideoPlayer from stop after just few frames

This commit is contained in:
2026-05-07 18:17:33 +10:00
parent a526aa6cdb
commit 2e0fee5e3d
6 changed files with 55 additions and 32 deletions
+10 -3
View File
@@ -59,6 +59,7 @@ CFilePlayer::CFilePlayer()
, m_bSeek(0)
, m_dSeekPos(0)
, m_nNalLength(0)
, m_bLooped(FALSE)
, m_pFormatContext(NULL)
, m_hReadThread(0)
, m_hVideoThread(0)
@@ -280,8 +281,9 @@ BOOL CFilePlayer::play()
{
return TRUE;
}
m_bPlaying = TRUE;
m_bLooped = FALSE; // fresh playback — no wrap yet
if (m_nVideoIndex >= 0)
{
@@ -440,12 +442,17 @@ BOOL CFilePlayer::readFrame()
return FALSE;
}
}
// File wrapped — flag it so the consumer (ANSVideoPlayer) can detect
// EOF without watching m_nCurPos, which is non-monotonic during normal
// playback (decode-order packet PTS + audio thread also writes to it).
m_bLooped = TRUE;
if (av_read_frame(m_pFormatContext, &pkt) != 0)
{
return FALSE;
}
}
}
else if (0 != rret)
{
return FALSE;