Skip to content

Commit

Permalink
VideoPlayer: continue normal playback if seek fails
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Jul 12, 2016
1 parent a78b5a6 commit d2af716
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
25 changes: 19 additions & 6 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,11 +1001,16 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()

bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
{
bool hitEnd = false;

if (!m_pInput)
return false;

if(time < 0)
if (time < 0)
{
time = 0;
hitEnd = true;
}

m_pkt.result = -1;
av_packet_unref(&m_pkt.pkt);
Expand All @@ -1027,8 +1032,8 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
return true;
}

if(!m_pInput->Seek(0, SEEK_POSSIBLE)
&& !m_pInput->IsStreamType(DVDSTREAM_TYPE_FFMPEG))
if (!m_pInput->Seek(0, SEEK_POSSIBLE) &&
!m_pInput->IsStreamType(DVDSTREAM_TYPE_FFMPEG))
{
CLog::Log(LOGDEBUG, "%s - input stream reports it is not seekable", __FUNCTION__);
return false;
Expand All @@ -1050,7 +1055,7 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
else if (ret < 0 && m_pInput->IsEOF())
ret = 0;

if(ret >= 0)
if (ret >= 0)
UpdateCurrentPTS();
}

Expand All @@ -1060,10 +1065,18 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
CLog::Log(LOGDEBUG, "%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)
if (startpts)
*startpts = DVD_MSEC_TO_TIME(time);

return (ret >= 0);
if (ret >= 0)
{
if (!hitEnd)
return true;
else
return false;
}
else
return false;
}

bool CDVDDemuxFFmpeg::SeekByte(int64_t pos)
Expand Down
17 changes: 15 additions & 2 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2517,8 +2517,21 @@ void CVideoPlayer::HandleMessages()

FlushBuffers(!msg.GetFlush(), start, msg.GetAccurate(), msg.GetSync());
}
else
CLog::Log(LOGWARNING, "error while seeking");
else if (m_pDemuxer)
{
CLog::Log(LOGDEBUG, "VideoPlayer: seek failed or hit end of stream");
// dts after successful seek
if (start == DVD_NOPTS_VALUE)
start = DVD_MSEC_TO_TIME(time) - m_State.time_offset;

m_State.dts = start;

FlushBuffers(false, start, false, true);
if (m_playSpeed != DVD_PLAYSPEED_PAUSE)
{
SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
}
}

// set flag to indicate we have finished a seeking request
if(!msg.GetTrickPlay())
Expand Down

0 comments on commit d2af716

Please sign in to comment.