Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPlayer: change GetTotalTime() to return milliseconds in an int64_t #1263

Merged
merged 1 commit into from Aug 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions xbmc/Application.cpp
Expand Up @@ -4522,7 +4522,7 @@ void CApplication::UpdateFileState()

if (m_progressTrackingItem->IsVideo())
{
if ((m_progressTrackingItem->IsDVDImage() || m_progressTrackingItem->IsDVDFile()) && m_pPlayer->GetTotalTime() > 15*60)
if ((m_progressTrackingItem->IsDVDImage() || m_progressTrackingItem->IsDVDFile()) && m_pPlayer->GetTotalTime() > 15*60*1000)
{
m_progressTrackingItem->GetVideoInfoTag()->m_streamDetails.Reset();
m_pPlayer->GetStreamDetails(m_progressTrackingItem->GetVideoInfoTag()->m_streamDetails);
Expand Down Expand Up @@ -5500,7 +5500,7 @@ double CApplication::GetTotalTime() const
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
rc = (*m_currentStack)[m_currentStack->Size() - 1]->m_lEndOffset;
else
rc = m_pPlayer->GetTotalTime();
rc = static_cast<double>(m_pPlayer->GetTotalTime() * 0.001f);
}

return rc;
Expand Down Expand Up @@ -5617,7 +5617,7 @@ float CApplication::GetCachePercentage() const
float stackedTotalTime = (float) GetTotalTime();
// We need to take into account the stack's total time vs. currently playing file's total time
if (stackedTotalTime > 0.0f)
return min( 100.0f, GetPercentage() + (m_pPlayer->GetCachePercentage() * m_pPlayer->GetTotalTime() / stackedTotalTime ) );
return min( 100.0f, GetPercentage() + (m_pPlayer->GetCachePercentage() * m_pPlayer->GetTotalTime() * 0.001f / stackedTotalTime ) );
}
else
return min( 100.0f, m_pPlayer->GetPercentage() + m_pPlayer->GetCachePercentage() );
Expand Down
10 changes: 10 additions & 0 deletions xbmc/Application.h
Expand Up @@ -221,7 +221,17 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
// Wakes up from the screensaver and / or DPMS. Returns true if woken up.
bool WakeUpScreenSaverAndDPMS(bool bPowerOffKeyPressed = false);
bool WakeUpScreenSaver(bool bPowerOffKeyPressed = false);
/*!
\brief Returns the total time in fractional seconds of the currently playing media

Beware that this method returns fractional seconds whereas IPlayer::GetTotalTime() returns milliseconds.
*/
double GetTotalTime() const;
/*!
\brief Returns the current time in fractional seconds of the currently playing media

Beware that this method returns fractional seconds whereas IPlayer::GetTime() returns milliseconds.
*/
double GetTime() const;
float GetPercentage() const;

Expand Down
13 changes: 6 additions & 7 deletions xbmc/cores/DummyVideoPlayer.cpp
Expand Up @@ -144,7 +144,7 @@ bool CDummyVideoPlayer::CanSeek()

void CDummyVideoPlayer::Seek(bool bPlus, bool bLargeStep)
{
if (g_advancedSettings.m_videoUseTimeSeeking && GetTotalTime() > 2*g_advancedSettings.m_videoTimeSeekForwardBig)
if (g_advancedSettings.m_videoUseTimeSeeking && GetTotalTime() > 2000*g_advancedSettings.m_videoTimeSeekForwardBig)
{
int seek = 0;
if (bLargeStep)
Expand Down Expand Up @@ -191,14 +191,13 @@ void CDummyVideoPlayer::SwitchToNextAudioLanguage()

void CDummyVideoPlayer::SeekPercentage(float iPercent)
{
int64_t iTotalMsec = GetTotalTime() * 1000;
int64_t iTime = (int64_t)(iTotalMsec * iPercent / 100);
int64_t iTime = (int64_t)(GetTotalTime() * iPercent / 100);
SeekTime(iTime);
}

float CDummyVideoPlayer::GetPercentage()
{
int64_t iTotalTime = GetTotalTime() * 1000;
int64_t iTotalTime = GetTotalTime();

if (iTotalTime != 0)
{
Expand Down Expand Up @@ -240,10 +239,10 @@ int64_t CDummyVideoPlayer::GetTime()
return m_clock;
}

// return length in seconds.. this should be changed to return in milleseconds throughout xbmc
int CDummyVideoPlayer::GetTotalTime()
// return length in milliseconds
int64_t CDummyVideoPlayer::GetTotalTime()
{
return 1000;
return 1000000;
}

void CDummyVideoPlayer::ToFFRW(int iSpeed)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/DummyVideoPlayer.h
Expand Up @@ -68,7 +68,7 @@ class CDummyVideoPlayer : public IPlayer, public CThread

virtual void SeekTime(int64_t iTime);
virtual int64_t GetTime();
virtual int GetTotalTime();
virtual int64_t GetTotalTime();
virtual void ToFFRW(int iSpeed);
virtual void ShowOSD(bool bOnoff);
virtual void DoAudioWork() {}
Expand Down
6 changes: 3 additions & 3 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Expand Up @@ -504,7 +504,7 @@ void CExternalPlayer::SeekPercentage(float iPercent)
float CExternalPlayer::GetPercentage()
{
int64_t iTime = GetTime();
int64_t iTotalTime = GetTotalTime() * 1000;
int64_t iTotalTime = GetTotalTime();

if (iTotalTime != 0)
{
Expand Down Expand Up @@ -547,9 +547,9 @@ int64_t CExternalPlayer::GetTime() // in millis
return m_time;
}

int CExternalPlayer::GetTotalTime() // in seconds
int64_t CExternalPlayer::GetTotalTime() // in milliseconds
{
return m_totalTime;
return m_totalTime * 1000;
}

void CExternalPlayer::ToFFRW(int iSpeed)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/ExternalPlayer/ExternalPlayer.h
Expand Up @@ -72,7 +72,7 @@ class CExternalPlayer : public IPlayer, public CThread

virtual void SeekTime(int64_t iTime);
virtual int64_t GetTime();
virtual int GetTotalTime();
virtual int64_t GetTotalTime();
virtual void ToFFRW(int iSpeed);
virtual void ShowOSD(bool bOnoff);
virtual void DoAudioWork() {}
Expand Down
10 changes: 8 additions & 2 deletions xbmc/cores/IPlayer.h
Expand Up @@ -135,8 +135,14 @@ class IPlayer

virtual float GetActualFPS() { return 0.0f; };
virtual void SeekTime(int64_t iTime = 0){};
virtual int64_t GetTime(){ return 0;};
virtual int GetTotalTime(){ return 0;};
/*!
\brief current time in milliseconds
*/
virtual int64_t GetTime() { return 0; }
/*!
\brief total time in milliseconds
*/
virtual int64_t GetTotalTime() { return 0; }
virtual int GetAudioBitrate(){ return 0;}
virtual int GetVideoBitrate(){ return 0;}
virtual int GetSourceBitrate(){ return 0;}
Expand Down
6 changes: 3 additions & 3 deletions xbmc/cores/amlplayer/AMLPlayer.cpp
Expand Up @@ -716,7 +716,7 @@ void CAMLPlayer::Seek(bool bPlus, bool bLargeStep)
int64_t seek_ms;
if (g_advancedSettings.m_videoUseTimeSeeking)
{
if (bLargeStep && (GetTotalTime() > (2 * g_advancedSettings.m_videoTimeSeekForwardBig)))
if (bLargeStep && (GetTotalTime() > (2000 * g_advancedSettings.m_videoTimeSeekForwardBig)))
seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForwardBig : g_advancedSettings.m_videoTimeSeekBackwardBig;
else
seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForward : g_advancedSettings.m_videoTimeSeekBackward;
Expand Down Expand Up @@ -1101,9 +1101,9 @@ __int64 CAMLPlayer::GetTime()
return m_elapsed_ms;
}

int CAMLPlayer::GetTotalTime()
__int64 CAMLPlayer::GetTotalTime()
{
return m_duration_ms / 1000;
return m_duration_ms;
}

int CAMLPlayer::GetAudioBitrate()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/amlplayer/AMLPlayer.h
Expand Up @@ -124,7 +124,7 @@ class CAMLPlayer : public IPlayer, public CThread
virtual float GetActualFPS();
virtual void SeekTime(__int64 iTime = 0);
virtual __int64 GetTime();
virtual int GetTotalTime();
virtual __int64 GetTotalTime();
virtual int GetAudioBitrate();
virtual int GetVideoBitrate();
virtual int GetSourceBitrate();
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/dvdplayer/DVDPlayer.cpp
Expand Up @@ -2241,7 +2241,7 @@ void CDVDPlayer::Seek(bool bPlus, bool bLargeStep)
}

int64_t seek;
if (g_advancedSettings.m_videoUseTimeSeeking && GetTotalTime() > 2*g_advancedSettings.m_videoTimeSeekForwardBig)
if (g_advancedSettings.m_videoUseTimeSeeking && GetTotalTime() > 2000*g_advancedSettings.m_videoTimeSeekForwardBig)
{
if (bLargeStep)
seek = bPlus ? g_advancedSettings.m_videoTimeSeekForwardBig : g_advancedSettings.m_videoTimeSeekBackwardBig;
Expand Down Expand Up @@ -2587,9 +2587,9 @@ int64_t CDVDPlayer::GetTotalTimeInMsec()
}

// return length in seconds.. this should be changed to return in milleseconds throughout xbmc
int CDVDPlayer::GetTotalTime()
int64_t CDVDPlayer::GetTotalTime()
{
return (int)(GetTotalTimeInMsec() / 1000);
return GetTotalTimeInMsec();
}

void CDVDPlayer::ToFFRW(int iSpeed)
Expand Down Expand Up @@ -3803,7 +3803,7 @@ bool CDVDPlayer::GetStreamDetails(CStreamDetails &details)
if (result && details.GetStreamCount(CStreamDetail::VIDEO) > 0) // this is more correct (dvds in particular)
{
GetVideoAspectRatio(((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect);
((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_iDuration = GetTotalTime();
((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_iDuration = GetTotalTime() / 1000;
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/dvdplayer/DVDPlayer.h
Expand Up @@ -219,7 +219,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer

virtual void SeekTime(int64_t iTime);
virtual int64_t GetTime();
virtual int GetTotalTime();
virtual int64_t GetTotalTime();
virtual void ToFFRW(int iSpeed);
virtual bool OnAction(const CAction &action);
virtual bool HasMenu();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/paplayer/PAPlayer.cpp
Expand Up @@ -789,9 +789,9 @@ int64_t PAPlayer::GetTotalTime64()
return total;
}

int PAPlayer::GetTotalTime()
int64_t PAPlayer::GetTotalTime()
{
return (int)m_playerGUIData.m_totalTime;
return m_playerGUIData.m_totalTime;
}

int PAPlayer::GetCacheLevel() const
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/paplayer/PAPlayer.h
Expand Up @@ -63,7 +63,7 @@ class PAPlayer : public IPlayer, public CThread
virtual void Update(bool bPauseDrawing = false) {}
virtual void ToFFRW(int iSpeed = 0);
virtual int GetCacheLevel() const;
virtual int GetTotalTime();
virtual int64_t GetTotalTime();
virtual int GetAudioBitrate();
virtual int GetChannels();
virtual int GetBitsPerSample();
Expand Down
6 changes: 3 additions & 3 deletions xbmc/network/AirPlayServer.cpp
Expand Up @@ -821,7 +821,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
if (g_application.m_pPlayer && g_application.m_pPlayer->GetTotalTime())
{
float position = ((float) g_application.m_pPlayer->GetTime()) / 1000;
responseBody.Format("duration: %d\r\nposition: %f", g_application.m_pPlayer->GetTotalTime(), position);
responseBody.Format("duration: %d\r\nposition: %f", g_application.m_pPlayer->GetTotalTime() / 1000, position);
}
else
{
Expand Down Expand Up @@ -921,9 +921,9 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
if (g_application.m_pPlayer->GetTotalTime())
{
position = ((float) g_application.m_pPlayer->GetTime()) / 1000;
duration = (float) g_application.m_pPlayer->GetTotalTime();
duration = ((float) g_application.m_pPlayer->GetTotalTime()) / 1000;
playing = g_application.m_pPlayer ? !g_application.m_pPlayer->IsPaused() : false;
cacheDuration = (float) g_application.m_pPlayer->GetTotalTime() * g_application.GetCachePercentage()/100.0f;
cacheDuration = (float) g_application.m_pPlayer->GetTotalTime() / 1000 * g_application.GetCachePercentage()/100.0f;
}

responseBody.Format(PLAYBACK_INFO, duration, cacheDuration, position, (playing ? 1 : 0), duration);
Expand Down