Fix VideoPlayer from stop after just few frames
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -53,6 +53,12 @@ public:
|
||||
BOOL seek(int pos);
|
||||
int64 getElapse() {return m_nCurPos;};
|
||||
int64 getDuration() {return m_nDuration;}
|
||||
// Set inside readFrame() when av_read_frame returns AVERROR_EOF and the
|
||||
// reader auto-loops via av_seek_frame. Caller (ANSVideoPlayer) polls this
|
||||
// to detect EOF without relying on m_nCurPos, which is non-monotonic
|
||||
// (decode-order packet PTS + audio thread also writes to it).
|
||||
BOOL hasLooped() {return m_bLooped;}
|
||||
void clearLooped() {m_bLooped = FALSE;}
|
||||
int getVideoCodec();
|
||||
int getAudioCodec();
|
||||
BOOL onRecord();
|
||||
@@ -79,7 +85,8 @@ private:
|
||||
int m_bSeek; // seek request
|
||||
double m_dSeekPos; // seek position, nit is millisecond
|
||||
int m_nNalLength;
|
||||
|
||||
BOOL m_bLooped; // set by readFrame() when EOF triggered an av_seek_frame back to start
|
||||
|
||||
AVFormatContext * m_pFormatContext; // format context
|
||||
|
||||
pthread_t m_hReadThread; // read thread
|
||||
|
||||
Reference in New Issue
Block a user