]> git.sesse.net Git - vlc/commitdiff
* all: added a new skin text variable "$S" to get the audio sample rate
authorCyril Deguet <asmax@videolan.org>
Sat, 15 Apr 2006 16:18:59 +0000 (16:18 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 15 Apr 2006 16:18:59 +0000 (16:18 +0000)
 (in KHz) + fixed the bitrate ("$B") variable to use only the audio bit rate.
* winamp2.xml: updated the winamp2 skin

doc/skins/skins2-howto.xml
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/utils/var_text.cpp
share/skins2/winamp2.xml
src/input/es_out.c
src/input/input.c

index af753655223c1c47bbbcb5f80bbff5601f636972..566cde564f47ebf3a0e78608a1fcbed4fe05f3d2 100644 (file)
@@ -921,7 +921,7 @@ difficulty to understand how VLC skins work.</para>
 
 <itemizedlist>
   <listitem><para>
-    <emphasis>$B</emphasis>: Get the stream bitrate (in kb/s).
+    <emphasis>$B</emphasis>: Get the audio stream bitrate (in kb/s).
   </para></listitem>
   <listitem><para>
     <emphasis>$V</emphasis>: Value of the volume (from 0 to 100 --> useful for a percentage).
@@ -948,6 +948,9 @@ difficulty to understand how VLC skins work.</para>
   <listitem><para>
     <emphasis>$F</emphasis>: Full name (with path) of the stream that is being played.
   </para></listitem>
+  <listitem><para>
+    <emphasis>$S</emphasis>: Get the audio sample rate (in kHz).
+  </para></listitem>
 </itemizedlist>
 
 <para>Example of <link linkend="slidertooltiptext">tooltiptext</link> value for a slider controlling the volume: "Volume: $V%".</para>
index bc978219773e5bc2ebce1f4e685e93ef8831ef92..e67f3c7da444821bedff56ab5b7fac5643d17293 100644 (file)
@@ -26,7 +26,6 @@
 #include <vlc/vout.h>
 #include <aout_internal.h>
 
-#include <math.h>
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
 #include "os_timer.hpp"
@@ -111,6 +110,8 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
     m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
+    m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
+    pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
 
     // Register the equalizer bands
     for( int i = 0; i < EqualizerBands::kNbBands; i++)
@@ -243,6 +244,7 @@ void VlcProc::manage()
     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
+    VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
 
     // Refresh audio variables
     refreshAudio();
@@ -295,11 +297,13 @@ void VlcProc::manage()
             vlc_object_release( pVout );
         }
 
-        // Get information on the current playlist item
-        input_item_t *pItem = pInput->input.p_item;
         // Get the input bitrate
-        int bitrate = (int)(roundf(pItem->p_stats->f_demux_bitrate*8000));
+        int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
+
+        // Get the audio sample rate
+        int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
+        pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
     }
     else
     {
index d298c13367c645e1a24e39280363bfedbe3a6393..b930b2f57ab0e2efd370416213841948ffcdf78d 100644 (file)
@@ -76,6 +76,10 @@ class VlcProc: public SkinObject
         VarText &getStreamBitRateVar()
             { return *((VarText*)(m_cVarStreamBitRate.get())); }
 
+        /// Getter for the stream sample rate variable
+        VarText &getStreamSampleRateVar()
+            { return *((VarText*)(m_cVarStreamSampleRate.get())); }
+
         /// Getter for the vout size variable
         VarBox &getVoutSizeVar() { return m_varVoutSize; }
 
@@ -115,6 +119,7 @@ class VlcProc: public SkinObject
         VariablePtr m_cVarStreamName;
         VariablePtr m_cVarStreamURI;
         VariablePtr m_cVarStreamBitRate;
+        VariablePtr m_cVarStreamSampleRate;
         /// Variable for the "mute" state
         VariablePtr m_cVarMute;
         /// Variables related to the input
index 7ca12fd7bc231ea02ff70cdcf394557854753cfb..e7740d296debcfc0ab888d7dc400e061b06c8ebd 100644 (file)
@@ -49,6 +49,7 @@ VarText::~VarText()
         pVlcProc->getStreamURIVar().delObserver( this );
         pVlcProc->getStreamNameVar().delObserver( this );
         pVlcProc->getStreamBitRateVar().delObserver( this );
+        pVlcProc->getStreamSampleRateVar().delObserver( this );
         VarManager *pVarManager = VarManager::instance( getIntf() );
         pVarManager->getHelpText().delObserver( this );
     }
@@ -126,6 +127,10 @@ const UString VarText::get() const
     {
         temp.replace( pos, 2, pVlcProc->getStreamBitRateVar().get() );
     }
+    while( (pos = temp.find( "$S" )) != UString::npos )
+    {
+        temp.replace( pos, 2, pVlcProc->getStreamSampleRateVar().get() );
+    }
 
     return temp;
 }
@@ -150,6 +155,7 @@ void VarText::set( const UString &rText )
         pVlcProc->getStreamNameVar().delObserver( this );
         pVlcProc->getStreamURIVar().delObserver( this );
         pVlcProc->getStreamBitRateVar().delObserver( this );
+        pVlcProc->getStreamSampleRateVar().delObserver( this );
         VarManager *pVarManager = VarManager::instance( getIntf() );
         pVarManager->getHelpText().delObserver( this );
 
@@ -189,6 +195,10 @@ void VarText::set( const UString &rText )
         {
             pVlcProc->getStreamBitRateVar().addObserver( this );
         }
+        if( m_text.find( "$S" ) != UString::npos )
+        {
+            pVlcProc->getStreamSampleRateVar().addObserver( this );
+        }
     }
 
     notify();
@@ -217,3 +227,4 @@ void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
         notify();
     }
 }
+
index 2371ff2d92acb74932b96e4a1d1e45530c8700b9..4f244436f3380bcb9ff8e9305a14ff7bb0e97660 100644 (file)
                 <Text font="digits_font;digits_font_2" x="30" y="26" width="72" text="$t" visible="not vlc.isStopped" scrolling="none" alignment="right" />
                 <Text font="text_font" x="111" y="27" width="155" text="$N" />
                 <Text font="text_font" x="111" y="43" width="15" text="$B" scrolling="none" alignment="right" />
+                <Text font="text_font" x="151" y="43" width="15" text="$S" scrolling="none" alignment="right" />
                 <Slider value="volume" x="107" y="57" up="volume_up" down="volume_down" points="(7,6),(58,6)" tooltiptext="Volume: $V%">
                     <SliderBackground image="volume_bg;volume_bg_2" nbvert="28" padvert="2" />
                 </Slider>
index 1197dffc1b9e6708e0813efa96173463ebeebbc3..862705c51e6b477a823afa8cded5c355cb7b5185 100644 (file)
@@ -1596,8 +1596,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
                            "%d", fmt->audio.i_channels );
 
         if( fmt->audio.i_rate > 0 )
+        {
             input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),
                            _("%d Hz"), fmt->audio.i_rate );
+            var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate );
+        }
 
         if( fmt->audio.i_bitspersample > 0 )
             input_Control( p_input, INPUT_ADD_INFO, psz_cat,
@@ -1605,8 +1608,11 @@ static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
                            fmt->audio.i_bitspersample );
 
         if( fmt->i_bitrate > 0 )
+        {
             input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),
                            _("%d kb/s"), fmt->i_bitrate / 1000 );
+            var_SetInteger( p_input, "bit-rate", fmt->i_bitrate );
+        }
         break;
 
     case VIDEO_ES:
index a3692dc93eae7300c9951c82590f38957cbdf3de..ca3c51c0dcbce4ac0a0159cce8a973341d7e70b5 100644 (file)
@@ -726,6 +726,9 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
     es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_FALSE );
     es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, ES_OUT_MODE_NONE );
 
+    var_Create( p_input, "bit-rate", VLC_VAR_INTEGER );
+    var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
+
     if( InputSourceInit( p_input, &p_input->input,
                          p_input->input.p_item->psz_uri, NULL, b_quick ) )
     {