Commit 7fca2ae3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout_VolumeGet: return volume directly

Only two call sites checked for errors. Anyway, the implementation does
not check for errors.
parent 67333b50
...@@ -312,8 +312,8 @@ VLC_EXPORT( aout_buffer_t *, aout_FifoPop, ( aout_instance_t * p_aout, aout_fifo ...@@ -312,8 +312,8 @@ VLC_EXPORT( aout_buffer_t *, aout_FifoPop, ( aout_instance_t * p_aout, aout_fifo
/* From intf.c : */ /* From intf.c : */
VLC_EXPORT( void, aout_VolumeSoftInit, ( aout_instance_t * ) ); VLC_EXPORT( void, aout_VolumeSoftInit, ( aout_instance_t * ) );
VLC_EXPORT( void, aout_VolumeNoneInit, ( aout_instance_t * ) ); VLC_EXPORT( void, aout_VolumeNoneInit, ( aout_instance_t * ) );
VLC_EXPORT( int, aout_VolumeGet, ( vlc_object_t *, audio_volume_t * ) ); VLC_EXPORT( audio_volume_t, aout_VolumeGet, ( vlc_object_t * ) );
#define aout_VolumeGet(a, b) aout_VolumeGet(VLC_OBJECT(a), b) #define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
VLC_EXPORT( int, aout_VolumeSet, ( vlc_object_t *, audio_volume_t ) ); VLC_EXPORT( int, aout_VolumeSet, ( vlc_object_t *, audio_volume_t ) );
#define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b) #define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
VLC_EXPORT( int, aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) ); VLC_EXPORT( int, aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) );
......
...@@ -154,12 +154,10 @@ DBUS_METHOD( VolumeGet ) ...@@ -154,12 +154,10 @@ DBUS_METHOD( VolumeGet )
REPLY_INIT; REPLY_INIT;
OUT_ARGUMENTS; OUT_ARGUMENTS;
dbus_int32_t i_dbus_vol; 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; double f_vol = 100. * i_vol / AOUT_VOLUME_MAX;
i_dbus_vol = round( f_vol ); i_dbus_vol = round( f_vol );
ADD_INT32( &i_dbus_vol ); ADD_INT32( &i_dbus_vol );
REPLY_SEND; REPLY_SEND;
......
...@@ -405,7 +405,7 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer, ...@@ -405,7 +405,7 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
state = "stop"; 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 ); snprintf( volume, sizeof(volume), "%d", (int)i_volume );
p_args->vars = mvar_New( "variables", "" ); p_args->vars = mvar_New( "variables", "" );
......
...@@ -256,7 +256,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -256,7 +256,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
int i_value; int i_value;
ExtractURIValue( p_request, "value", vol, 8 ); 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 ); decode_URI( vol );
if( vol[0] == '+' ) if( vol[0] == '+' )
......
...@@ -921,7 +921,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -921,7 +921,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
char *psz_vol = SSPop( st ); char *psz_vol = SSPop( st );
int i_value; int i_value;
audio_volume_t i_volume; 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] == '+' ) if( psz_vol[0] == '+' )
{ {
i_value = atoi( psz_vol ); i_value = atoi( psz_vol );
...@@ -952,7 +952,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -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; if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
aout_VolumeSet( p_sys->p_playlist, i_value ); 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 ); free( psz_vol );
} }
else if( !strcmp( s, "vlc_get_meta" ) ) else if( !strcmp( s, "vlc_get_meta" ) )
......
...@@ -1516,12 +1516,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1516,12 +1516,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
else else
{ {
/* Get. */ /* Get. */
audio_volume_t i_volume; audio_volume_t i_volume = aout_VolumeGet( p_playlist );
if ( !aout_VolumeGet( p_playlist, &i_volume ) ) msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
{ i_error = VLC_SUCCESS;
msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
i_error = VLC_SUCCESS;
}
} }
return i_error; return i_error;
......
...@@ -1667,7 +1667,7 @@ static void manage_cleanup( void * args ) ...@@ -1667,7 +1667,7 @@ static void manage_cleanup( void * args )
audio_volume_t i_volume; audio_volume_t i_volume;
playlist_t * p_playlist = pl_Get( p_intf ); 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 ) if( i_volume != i_lastShownVolume )
{ {
......
...@@ -1132,7 +1132,7 @@ static int DrawStatus(intf_thread_t *p_intf) ...@@ -1132,7 +1132,7 @@ static int DrawStatus(intf_thread_t *p_intf)
mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2); 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%%"), mvnprintw(y++, 0, COLS, _(" Volume : %i%%"),
i_volume*200/AOUT_VOLUME_MAX); i_volume*200/AOUT_VOLUME_MAX);
......
...@@ -160,7 +160,7 @@ void SoundWidget::libUpdateVolume() ...@@ -160,7 +160,7 @@ void SoundWidget::libUpdateVolume()
audio_volume_t i_volume; audio_volume_t i_volume;
playlist_t *p_playlist = pl_Get( p_intf ); 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); i_volume = ( ( i_volume + 1 ) * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
int i_gauge = volumeSlider->value(); int i_gauge = volumeSlider->value();
if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */ if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */
......
...@@ -694,8 +694,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal ) ...@@ -694,8 +694,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
(void)p_obj; (void)newVal; (void)p_obj; (void)newVal;
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist; playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
audio_volume_t volume; audio_volume_t volume = aout_VolumeGet( pPlaylist );
aout_VolumeGet( pPlaylist, &volume );
SET_VOLUME( m_cVarVolume, volume, false ); SET_VOLUME( m_cVarVolume, volume, false );
SET_BOOL( m_cVarMute, volume == 0 ); SET_BOOL( m_cVarMute, volume == 0 );
} }
...@@ -797,8 +796,7 @@ void VlcProc::init_variables() ...@@ -797,8 +796,7 @@ void VlcProc::init_variables()
SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) ); SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) ); SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
audio_volume_t volume; audio_volume_t volume = aout_VolumeGet( pPlaylist );
aout_VolumeGet( pPlaylist, &volume );
SET_VOLUME( m_cVarVolume, volume, false ); SET_VOLUME( m_cVarVolume, volume, false );
SET_BOOL( m_cVarMute, volume == 0 ); SET_BOOL( m_cVarMute, volume == 0 );
......
...@@ -46,9 +46,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf ) ...@@ -46,9 +46,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
} }
// Initial value // Initial value
audio_volume_t val; audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
aout_VolumeGet( getIntf()->p_sys->p_playlist, &val );
set( val, false ); set( val, false );
} }
......
...@@ -61,11 +61,8 @@ static int vlclua_volume_set( lua_State *L ) ...@@ -61,11 +61,8 @@ static int vlclua_volume_set( lua_State *L )
static int vlclua_volume_get( lua_State *L ) static int vlclua_volume_get( lua_State *L )
{ {
playlist_t *p_this = vlclua_get_playlist_internal( L ); playlist_t *p_this = vlclua_get_playlist_internal( L );
audio_volume_t i_volume; audio_volume_t i_volume = aout_VolumeGet( p_this );
if( aout_VolumeGet( p_this, &i_volume ) == VLC_SUCCESS ) lua_pushnumber( L, i_volume );
lua_pushnumber( L, i_volume );
else
lua_pushnil( L );
return 1; return 1;
} }
......
...@@ -123,24 +123,17 @@ static void cancelVolume (vlc_object_t *obj, aout_instance_t *aout) ...@@ -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). * 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 #if 0
aout_instance_t *aout; aout_instance_t *aout;
int ret;
audio_volume_t volume; audio_volume_t volume;
bool mute;
prepareVolume (obj, &aout, &volume, &mute); prepareVolume (obj, &aout, &volume, NULL);
cancelVolume (obj, aout); 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; return 0;
#else
return config_GetInt (obj, "volume");
#endif #endif
} }
......
...@@ -326,9 +326,7 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute ) ...@@ -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 ) int libvlc_audio_get_volume( libvlc_media_player_t *mp )
{ {
audio_volume_t i_volume; audio_volume_t i_volume = aout_VolumeGet( mp );
aout_VolumeGet( mp, &i_volume );
return (i_volume*200+AOUT_VOLUME_MAX/2)/AOUT_VOLUME_MAX; return (i_volume*200+AOUT_VOLUME_MAX/2)/AOUT_VOLUME_MAX;
} }
......
...@@ -882,8 +882,7 @@ char *str_format_meta( vlc_object_t *p_object, const char *string ) ...@@ -882,8 +882,7 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
break; break;
case 'V': case 'V':
{ {
audio_volume_t volume; audio_volume_t volume = aout_VolumeGet( p_object );
aout_VolumeGet( p_object, &volume );
snprintf( buf, 10, "%d", volume ); snprintf( buf, 10, "%d", volume );
INSERT_STRING_NO_FREE( buf ); INSERT_STRING_NO_FREE( buf );
break; break;
......
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