Commit 77aa98d0 authored by JP Dinger's avatar JP Dinger

Skins2: Cosmetics and drop const from string return as there really is no...

Skins2: Cosmetics and drop const from string return as there really is no point: We're returning a fresh object.
parent c288689c
......@@ -42,7 +42,7 @@ void StreamTime::set( float percentage, bool updateVLC )
}
const string StreamTime::getAsStringPercent() const
string StreamTime::getAsStringPercent() const
{
int value = (int)(100. * get());
// 0 <= value <= 100, so we need 4 chars
......@@ -52,7 +52,27 @@ const string StreamTime::getAsStringPercent() const
}
const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
string StreamTime::formatTime( int seconds, bool bShortFormat ) const
{
char psz_time[MSTRTIME_MAX_SIZE];
if( bShortFormat && (seconds < 60 * 60) )
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%02d:%02d",
(int) (seconds / 60 % 60),
(int) (seconds % 60) );
}
else
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
(int) (seconds / (60 * 60)),
(int) (seconds / 60 % 60),
(int) (seconds % 60) );
}
return string(psz_time);
}
string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
......@@ -62,7 +82,7 @@ const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
}
const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
......@@ -74,7 +94,7 @@ const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
}
const string StreamTime::getAsStringDuration( bool bShortFormat ) const
string StreamTime::getAsStringDuration( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
......@@ -82,23 +102,3 @@ const string StreamTime::getAsStringDuration( bool bShortFormat ) const
mtime_t time = var_GetTime( getIntf()->p_sys->p_input, "length" );
return formatTime( time / 1000000, bShortFormat );
}
const string StreamTime::formatTime( int seconds, bool bShortFormat ) const
{
char psz_time[MSTRTIME_MAX_SIZE];
if( bShortFormat && (seconds < 60 * 60) )
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%02d:%02d",
(int) (seconds / 60 % 60),
(int) (seconds % 60) );
}
else
{
snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
(int) (seconds / (60 * 60)),
(int) (seconds / 60 % 60),
(int) (seconds % 60) );
}
return string(psz_time);
}
......@@ -40,17 +40,17 @@ public:
virtual void set( float percentage ) { set( percentage, true ); }
/// Return a string containing a value from 0 to 100
virtual const string getAsStringPercent() const;
virtual string getAsStringPercent() const;
/// Return the current time formatted as a time display (h:mm:ss)
virtual const string getAsStringCurrTime( bool bShortFormat = false ) const;
virtual string getAsStringCurrTime( bool bShortFormat = false ) const;
/// Return the time left formatted as a time display (h:mm:ss)
virtual const string getAsStringTimeLeft( bool bShortFormat = false ) const;
virtual string getAsStringTimeLeft( bool bShortFormat = false ) const;
/// Return the duration formatted as a time display (h:mm:ss)
virtual const string getAsStringDuration( bool bShortFormat = false ) const;
virtual string getAsStringDuration( bool bShortFormat = false ) const;
private:
/// Convert a number of seconds into "h:mm:ss" format
const string formatTime( int seconds, bool bShortFormat ) const;
string formatTime( int seconds, bool bShortFormat ) const;
/// Return true when there is a non-null input and its position is not 0.0.
bool havePosition() const;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment