]> git.sesse.net Git - vlc/commitdiff
aout_VolumeGet: return volume directly
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 7 Apr 2011 20:03:43 +0000 (23:03 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 7 Apr 2011 20:03:43 +0000 (23:03 +0300)
Only two call sites checked for errors. Anyway, the implementation does
not check for errors.

15 files changed:
include/vlc_aout.h
modules/control/dbus/dbus_player.c
modules/control/http/http.c
modules/control/http/macro.c
modules/control/http/rpn.c
modules/control/rc.c
modules/gui/macosx/intf.m
modules/gui/ncurses.c
modules/gui/qt4/components/controller_widget.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/vars/volume.cpp
modules/lua/libs/volume.c
src/audio_output/intf.c
src/control/audio.c
src/text/strings.c

index 2da4775bda080275bc299d0dfe1359c0c0a44f4f..f78970cbb52cdfb7c3f385790cc22cc044597706 100644 (file)
@@ -312,8 +312,8 @@ VLC_EXPORT( aout_buffer_t *, aout_FifoPop, ( aout_instance_t * p_aout, aout_fifo
 /* From intf.c : */
 VLC_EXPORT( void, aout_VolumeSoftInit, ( aout_instance_t * ) );
 VLC_EXPORT( void, aout_VolumeNoneInit, ( aout_instance_t * ) );
-VLC_EXPORT( int, aout_VolumeGet, ( vlc_object_t *, audio_volume_t * ) );
-#define aout_VolumeGet(a, b) aout_VolumeGet(VLC_OBJECT(a), b)
+VLC_EXPORT( audio_volume_t, aout_VolumeGet, ( vlc_object_t * ) );
+#define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
 VLC_EXPORT( int, aout_VolumeSet, ( vlc_object_t *, audio_volume_t ) );
 #define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
 VLC_EXPORT( int, aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) );
index 54d1af1a9292f1c2dcb5ad3666006d1646d6e8a1..359ccfe82a4dfe6280b57498f9b57d686a54e989 100644 (file)
@@ -154,12 +154,10 @@ DBUS_METHOD( VolumeGet )
     REPLY_INIT;
     OUT_ARGUMENTS;
     dbus_int32_t i_dbus_vol;
-    audio_volume_t i_vol;
-
-    /* 2nd argument of aout_VolumeGet is int32 */
-    aout_VolumeGet( PL, &i_vol );
 
+    audio_volume_t i_vol = aout_VolumeGet( PL );
     double f_vol = 100. * i_vol / AOUT_VOLUME_MAX;
+
     i_dbus_vol = round( f_vol );
     ADD_INT32( &i_dbus_vol );
     REPLY_SEND;
index 59eba58672d2ad305b2397823692393e398fd182..b53c557cdf4c176649508b2ebfec364bebe8b14f 100644 (file)
@@ -405,7 +405,7 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
         state = "stop";
     }
 
-    aout_VolumeGet( p_sys->p_playlist, &i_volume );
+    i_volume = aout_VolumeGet( p_sys->p_playlist );
     snprintf( volume, sizeof(volume), "%d", (int)i_volume );
 
     p_args->vars = mvar_New( "variables", "" );
index a0e330220cbe32b6bbe71a00e7f00a1ab68b059d..6e6e50cbf887a180f5b09af2283d68642397bfe3 100644 (file)
@@ -256,7 +256,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
                     int i_value;
 
                     ExtractURIValue( p_request, "value", vol, 8 );
-                    aout_VolumeGet( p_sys->p_playlist, &i_volume );
+                    i_volume = aout_VolumeGet( p_sys->p_playlist );
                     decode_URI( vol );
 
                     if( vol[0] == '+' )
index 289d45b650fc2d59a9ee9a086ec56b0ff82a674a..af67c67748a46e3bc2c9d69c3ebe28d904357219 100644 (file)
@@ -921,7 +921,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
             char *psz_vol = SSPop( st );
             int i_value;
             audio_volume_t i_volume;
-            aout_VolumeGet( p_sys->p_playlist, &i_volume );
+            i_volume = aout_VolumeGet( p_sys->p_playlist );
             if( psz_vol[0] == '+' )
             {
                 i_value = atoi( psz_vol );
@@ -952,7 +952,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
                 aout_VolumeSet( p_sys->p_playlist, i_value );
             }
-            aout_VolumeGet( p_sys->p_playlist, &i_volume );
+            i_volume = aout_VolumeGet( p_sys->p_playlist );
             free( psz_vol );
         }
         else if( !strcmp( s, "vlc_get_meta" ) )
index c6310b0d9356dea20c02104e59fa247272cb41bf..9798d5f30717cd579790105dd78ac810e8b8aed2 100644 (file)
@@ -1516,12 +1516,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
     else
     {
         /* Get. */
-        audio_volume_t i_volume;
-        if ( !aout_VolumeGet( p_playlist, &i_volume ) )
-        {
-            msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
-            i_error = VLC_SUCCESS;
-        }
+        audio_volume_t i_volume = aout_VolumeGet( p_playlist );
+        msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+        i_error = VLC_SUCCESS;
     }
 
     return i_error;
index a0e753b84fd303c7f5c6e1c87cbe31d34db0be5c..f1a50d9cbb1a3e3afb7343caa41ab1611ce1f094 100644 (file)
@@ -1667,7 +1667,7 @@ static void manage_cleanup( void * args )
     audio_volume_t i_volume;
     playlist_t * p_playlist = pl_Get( p_intf );
 
-    aout_VolumeGet( p_playlist, &i_volume );
+    i_volume = aout_VolumeGet( p_playlist );
 
     if( i_volume != i_lastShownVolume )
     {
index 33087e013ece5205ef1986fa6d95e77ae5477e7e..b920f5b5c65328c3b720e0aa8d8b73051cadcce7 100644 (file)
@@ -1132,7 +1132,7 @@ static int DrawStatus(intf_thread_t *p_intf)
 
             mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
 
-            aout_VolumeGet(p_playlist, &i_volume);
+            i_volume = aout_VolumeGet(p_playlist);
             mvnprintw(y++, 0, COLS, _(" Volume   : %i%%"),
                        i_volume*200/AOUT_VOLUME_MAX);
 
index b6208b5b6708d65fb4a73d424ac03dd6a008c9c6..38ff00c9f7033430a9e5b482745794ab4c0c3a6b 100644 (file)
@@ -160,7 +160,7 @@ void SoundWidget::libUpdateVolume()
     audio_volume_t i_volume;
     playlist_t *p_playlist = pl_Get( p_intf );
 
-    aout_VolumeGet( p_playlist, &i_volume );
+    i_volume = aout_VolumeGet( p_playlist );
     i_volume = ( ( i_volume + 1 ) *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
     int i_gauge = volumeSlider->value();
     if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */
index 02519e945699f46b0ac00cdea8a48ceeea0bfe9d..d44841297a78891ebc69f9513485e02238ca7b6b 100644 (file)
@@ -694,8 +694,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
     (void)p_obj; (void)newVal;
     playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
 
-    audio_volume_t volume;
-    aout_VolumeGet( pPlaylist, &volume );
+    audio_volume_t volume = aout_VolumeGet( pPlaylist );
     SET_VOLUME( m_cVarVolume, volume, false );
     SET_BOOL( m_cVarMute, volume == 0 );
 }
@@ -797,8 +796,7 @@ void VlcProc::init_variables()
     SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
     SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
 
-    audio_volume_t volume;
-    aout_VolumeGet( pPlaylist, &volume );
+    audio_volume_t volume = aout_VolumeGet( pPlaylist );
     SET_VOLUME( m_cVarVolume, volume, false );
     SET_BOOL( m_cVarMute, volume == 0 );
 
index 6aacfe677d73af4698bac6126bd524b9c47eb1f6..d7654f33b82b033cc6c3ed8c618c9875146b6789 100644 (file)
@@ -46,9 +46,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
     }
 
     // Initial value
-    audio_volume_t val;
-
-    aout_VolumeGet( getIntf()->p_sys->p_playlist, &val );
+    audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
     set( val, false );
 }
 
index afa15dceb472a39b90163673bc81741784592179..f9e038d987d6aa5d4cdf846cca337dbbe2e6b2a7 100644 (file)
@@ -61,11 +61,8 @@ static int vlclua_volume_set( lua_State *L )
 static int vlclua_volume_get( lua_State *L )
 {
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    audio_volume_t i_volume;
-    if( aout_VolumeGet( p_this, &i_volume ) == VLC_SUCCESS )
-        lua_pushnumber( L, i_volume );
-    else
-        lua_pushnil( L );
+    audio_volume_t i_volume = aout_VolumeGet( p_this );
+    lua_pushnumber( L, i_volume );
     return 1;
 }
 
index 4fb85ae3eedf828041a062e4743deaf19e6cf2d2..810cadd8f487285c17c4336cbdca41c6de41a055 100644 (file)
@@ -123,24 +123,17 @@ static void cancelVolume (vlc_object_t *obj, aout_instance_t *aout)
 /**
  * Gets the volume of the output device (independent of mute).
  */
-int aout_VolumeGet (vlc_object_t *obj, audio_volume_t *volp)
+audio_volume_t aout_VolumeGet (vlc_object_t *obj)
 {
 #if 0
     aout_instance_t *aout;
-    int ret;
     audio_volume_t volume;
-    bool mute;
 
-    prepareVolume (obj, &aout, &volume, &mute);
+    prepareVolume (obj, &aout, &volume, NULL);
     cancelVolume (obj, aout);
-    mute = !mute;
-    ret = commitVolume (obj, aout, volume, mute);
-    if (volp != NULL)
-        *volp = mute ? AOUT_VOLUME_MIN : volume;
-    return ret;
-#else
-    *volp = config_GetInt (obj, "volume");
     return 0;
+#else
+    return config_GetInt (obj, "volume");
 #endif
 }
 
index a6e7888c3fb8833a6212438c62c2ccbf40c0c532..0d5aa1b2c074dab8730973f9573d431a656fe20a 100644 (file)
@@ -326,9 +326,7 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
  *****************************************************************************/
 int libvlc_audio_get_volume( libvlc_media_player_t *mp )
 {
-    audio_volume_t i_volume;
-
-    aout_VolumeGet( mp, &i_volume );
+    audio_volume_t i_volume = aout_VolumeGet( mp );
 
     return (i_volume*200+AOUT_VOLUME_MAX/2)/AOUT_VOLUME_MAX;
 }
index 7a8fc87ee02d776d9fa415149405db3536798a89..3765077b4aa9f1de386f441445980b5e333dba00 100644 (file)
@@ -882,8 +882,7 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
                     break;
                 case 'V':
                 {
-                    audio_volume_t volume;
-                    aout_VolumeGet( p_object, &volume );
+                    audio_volume_t volume = aout_VolumeGet( p_object );
                     snprintf( buf, 10, "%d", volume );
                     INSERT_STRING_NO_FREE( buf );
                     break;