Skip to content

Commit

Permalink
[seek] improves instant seek in seek handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaggi committed Apr 11, 2015
1 parent 3fd4e1a commit a69dde3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions xbmc/utils/SeekHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ int CSeekHandler::GetSeekSeconds(bool forward, SeekType type)

void CSeekHandler::Seek(bool forward, float amount, float duration /* = 0 */, bool analogSeek /* = false */, SeekType type /* = SEEK_TYPE_VIDEO */)
{
// abort if we do not have a play time or already perform a seek
if (g_infoManager.GetTotalPlayTime() == 0 ||
g_infoManager.m_performingSeek)
return;

CSingleLock lock(m_critSection);

// not yet seeking
if (!m_requireSeek)
{
if (g_infoManager.GetTotalPlayTime())
m_percent = static_cast<float>(g_infoManager.GetPlayTime()) / g_infoManager.GetTotalPlayTime() * 0.1f;
else
m_percent = 0.0f;
m_percent = static_cast<float>(g_infoManager.GetPlayTime()) / g_infoManager.GetTotalPlayTime() * 0.1f;
m_percentPlayTime = m_percent;

// tell info manager that we have started a seek operation
Expand Down Expand Up @@ -159,10 +163,7 @@ void CSeekHandler::Seek(bool forward, float amount, float duration /* = 0 */, bo
int seekSeconds = GetSeekSeconds(forward, type);
if (seekSeconds != 0)
{
float percentPerSecond = 0.0f;
if (g_infoManager.GetTotalPlayTime())
percentPerSecond = 100.0f / static_cast<float>(g_infoManager.GetTotalPlayTime());

float percentPerSecond = 100.0f / static_cast<float>(g_infoManager.GetTotalPlayTime());
m_percent = m_percentPlayTime + percentPerSecond * seekSeconds;

g_infoManager.SetSeekStepSize(seekSeconds);
Expand All @@ -186,7 +187,10 @@ void CSeekHandler::Seek(bool forward, float amount, float duration /* = 0 */, bo

void CSeekHandler::SeekSeconds(int seconds)
{
if (seconds == 0 || g_infoManager.GetTotalPlayTime() == 0)
// abort if we do not have a play time or already perform a seek
if (seconds == 0 ||
g_infoManager.GetTotalPlayTime() == 0 ||
g_infoManager.m_performingSeek)
return;

CSingleLock lock(m_critSection);
Expand Down Expand Up @@ -222,7 +226,7 @@ bool CSeekHandler::InProgress() const

void CSeekHandler::Process()
{
if (m_timer.GetElapsedMilliseconds() > m_seekDelay && m_requireSeek)
if (m_timer.GetElapsedMilliseconds() >= m_seekDelay && m_requireSeek)
{
g_infoManager.m_performingSeek = true;

Expand Down

0 comments on commit a69dde3

Please sign in to comment.