Commit 5c277fc5 authored by Erwan Tulou's avatar Erwan Tulou

skins2: add $R to display current playback speed

parent 863692af
......@@ -75,6 +75,11 @@ void VlcProc::destroy( intf_thread_t *pIntf )
pIntf->p_sys->p_vlcProc = NULL;
}
#define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
#define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
#define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
#define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
#define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
......@@ -125,6 +130,9 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
#undef REGISTER_VAR
m_cVarSpeed = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarSpeed, "speed" );
SET_TEXT( m_cVarSpeed, UString( getIntf(), "1") );
m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamName, "streamName" );
m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
......@@ -440,6 +448,7 @@ int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
{
case INPUT_EVENT_STATE:
case INPUT_EVENT_POSITION:
case INPUT_EVENT_RATE:
case INPUT_EVENT_ES:
case INPUT_EVENT_CHAPTER:
case INPUT_EVENT_RECORD:
......@@ -468,12 +477,6 @@ int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
}
#define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
#define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
#define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
#define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
#define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
(void)p_obj;
......@@ -534,6 +537,18 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
break;
}
case INPUT_EVENT_RATE:
{
float rate = var_GetFloat( pInput, "rate" );
char* buffer;
if( asprintf( &buffer, "%.3g", rate ) != -1 )
{
SET_TEXT( m_cVarSpeed, UString( getIntf(), buffer ) );
free( buffer );
}
break;
}
case INPUT_EVENT_ES:
{
// Do we have audio
......
......@@ -65,6 +65,10 @@ public:
/// Getter for the volume variable
Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
/// Getter for the current playback speed
VarText &getSpeedVar()
{ return *((VarText*)(m_cVarSpeed.get())); }
/// Getter for the stream name variable
VarText &getStreamNameVar()
{ return *((VarText*)(m_cVarStreamName.get())); }
......@@ -129,6 +133,8 @@ private:
VariablePtr m_cVarTime;
/// Variable for audio volume
VariablePtr m_cVarVolume;
/// Variable for speed playback
VariablePtr m_cVarSpeed;
/// Variable for current stream properties
VariablePtr m_cVarStreamName;
VariablePtr m_cVarStreamURI;
......
......@@ -123,6 +123,10 @@ const UString VarText::get() const
{
temp.replace( pos, 2, pVlcProc->getStreamSampleRateVar().get() );
}
while( (pos = temp.find( "$R" )) != UString::npos )
{
temp.replace( pos, 2, pVlcProc->getSpeedVar().get() );
}
return temp;
}
......@@ -180,6 +184,10 @@ void VarText::set( const UString &rText )
{
pVlcProc->getStreamSampleRateVar().addObserver( this );
}
if( m_text.find( "$R" ) != UString::npos )
{
pVlcProc->getSpeedVar().addObserver( this );
}
}
notify();
......@@ -223,6 +231,7 @@ void VarText::delObservers()
{
pVlcProc->getTimeVar().delObserver( this );
pVlcProc->getVolumeVar().delObserver( this );
pVlcProc->getSpeedVar().delObserver( this );
pVlcProc->getStreamNameVar().delObserver( this );
pVlcProc->getStreamURIVar().delObserver( this );
pVlcProc->getStreamBitRateVar().delObserver( this );
......
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