Commit 09161bc3 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Added --volume-step to override AOUT_VOLUME_DEFAULT. This will give an OSD...

Added --volume-step to override AOUT_VOLUME_DEFAULT. This will give an OSD menu (or skins2) designer to freedom to decide how many steps he wants for turning up the volume from 0 to 1024. It is an advanced option so most users will never see it. Can someone check the MacOSX changes for this? I made them but cannot compiler and test it (I don't have a Mac).
parent 04f2f137
......@@ -756,7 +756,7 @@ static void Run( intf_thread_t *p_intf )
break;
}
vlc_mutex_unlock( &p_playlist->object_lock );
} /* End of current playlist status */
} /* End of current playlist status */
}
}
else if( !strcmp( psz_cmd, "get_time" ) )
......@@ -860,7 +860,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_playlist );
p_playlist = NULL;
}
var_DelCallback( p_intf->p_vlc, "volume", VolumeChanged, p_intf );
}
......@@ -971,7 +971,7 @@ static int VolumeChanged( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t*)p_data;
vlc_mutex_lock( &p_intf->p_sys->status_lock );
msg_rc( STATUS_CHANGE "( audio volume: %d )", newval.i_int );
vlc_mutex_unlock( &p_intf->p_sys->status_lock );
......@@ -984,7 +984,7 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
intf_thread_t *p_intf = (intf_thread_t*)p_data;
playlist_t *p_playlist = NULL;
input_thread_t *p_input = NULL;
vlc_mutex_lock( &p_intf->p_sys->status_lock );
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input )
......@@ -1247,7 +1247,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
if( p_playlist->p_input )
{
vlc_value_t val;
var_Get( p_playlist->p_input, "rate", &val );
if( val.i_int != INPUT_RATE_DEFAULT )
{
......@@ -1718,8 +1718,10 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
audio_volume_t i_volume;
int i_nb_steps = atoi(newval.psz_string);
int i_error = VLC_SUCCESS;
int i_volume_step = 0;
if ( i_nb_steps <= 0 || i_nb_steps > (AOUT_VOLUME_MAX/AOUT_VOLUME_STEP) )
i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
if ( i_nb_steps <= 0 || i_nb_steps > (AOUT_VOLUME_MAX/i_volume_step) )
{
i_nb_steps = 1;
}
......
......@@ -250,7 +250,9 @@
{
intf_thread_t * p_intf = VLCIntf;
audio_volume_t i_volume = (audio_volume_t)[sender intValue];
aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
int i_volume_step = 0;
i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
aout_VolumeSet( p_intf, i_volume * i_volume_step );
/* Manage volume status */
[o_main manageVolumeSlider];
}
......
......@@ -1018,11 +1018,12 @@ static VLCMain *_o_sharedMainInstance = nil;
if( p_intf->p_sys->b_volume_update )
{
NSString *o_text;
int i_volume_step = 0;
o_text = [NSString stringWithFormat: _NS("Volume: %d%%"), i_lastShownVolume * 400 / AOUT_VOLUME_MAX];
if( i_lastShownVolume != -1 )
[self setScrollField:o_text stopAfter:1000000];
[o_volumeslider setFloatValue: (float)i_lastShownVolume / AOUT_VOLUME_STEP];
i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
[o_volumeslider setFloatValue: (float)i_lastShownVolume / i_volume_step];
[o_volumeslider setEnabled: TRUE];
p_intf->p_sys->b_mute = ( i_lastShownVolume == 0 );
p_intf->p_sys->b_volume_update = FALSE;
......
......@@ -147,10 +147,11 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
{
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
int i_result = 0, i_volume = 0;
int i_result = 0, i_volume = 0, i_volume_step = 0;
i_volume_step = config_GetInt( p_object->p_vlc, "volume-step" );
i_volume = config_GetInt( p_object, "volume" );
i_volume += AOUT_VOLUME_STEP * i_nb_steps;
i_volume += i_volume_step * i_nb_steps;
if ( i_volume > AOUT_VOLUME_MAX )
{
i_volume = AOUT_VOLUME_MAX;
......@@ -184,10 +185,11 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
{
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
int i_result = 0, i_volume = 0;
int i_result = 0, i_volume = 0, i_volume_step = 0;
i_volume_step = config_GetInt( p_object->p_vlc, "volume-step" );
i_volume = config_GetInt( p_object, "volume" );
i_volume -= AOUT_VOLUME_STEP * i_nb_steps;
i_volume -= i_volume_step * i_nb_steps;
if ( i_volume < AOUT_VOLUME_MIN )
{
i_volume = AOUT_VOLUME_MIN;
......
......@@ -124,6 +124,11 @@ static char *ppsz_snap_formats[] =
#define VOLUME_SAVE_LONGTEXT N_( \
"This saves the audio output volume when you select mute.")
#define VOLUME_STEP_TEXT N_("Audio output volume step")
#define VOLUME_STEP_LONGTEXT N_( \
"The step size of the volume is adjustable using this option, " \
"in a range from 0 to 1024." )
#define AOUT_RATE_TEXT N_("Audio output frequency (Hz)")
#define AOUT_RATE_LONGTEXT N_( \
"You can force the audio output frequency here. Common values are " \
......@@ -942,6 +947,9 @@ vlc_module_begin();
add_integer_with_range( "volume", AOUT_VOLUME_DEFAULT, AOUT_VOLUME_MIN,
AOUT_VOLUME_MAX, NULL, VOLUME_TEXT,
VOLUME_LONGTEXT, VLC_FALSE );
add_integer_with_range( "volume-step", AOUT_VOLUME_STEP, AOUT_VOLUME_MIN,
AOUT_VOLUME_MAX, NULL, VOLUME_STEP_TEXT,
VOLUME_STEP_LONGTEXT, VLC_TRUE );
add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT,
AOUT_RATE_LONGTEXT, VLC_TRUE );
#if !defined( SYS_DARWIN )
......
......@@ -33,16 +33,17 @@
#undef OSD_MENU_DEBUG
/* 3 is a magic number for 32 volume decrease steps */
#define OSD_VOLUME_STEPS(i_volume,i_n) (i_volume/AOUT_VOLUME_STEP) / (AOUT_VOLUME_STEP/(i_n-1))
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );
static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
static int osd_VolumeStep( vlc_object_t *, int, int );
/*****************************************************************************
* OSD menu Funtions
*****************************************************************************/
osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
{
osd_menu_t *p_osd = NULL;
......@@ -80,7 +81,7 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
/* Update the volume state images to match the current volume */
i_volume = config_GetInt( p_this, "volume" );
i_steps = OSD_VOLUME_STEPS( i_volume, p_osd->p_state->p_volume->i_ranges );
i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges );
p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );
/* Initialize OSD state */
......@@ -526,6 +527,14 @@ void __osd_MenuDown( vlc_object_t *p_this )
vlc_mutex_unlock( lockval.p_address );
}
static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )
{
int i_volume_step = 0;
i_volume_step = config_GetInt( p_this->p_vlc, "volume-step" );
return (i_volume/i_volume_step);
}
/**
* Display current audio volume bitmap
*
......@@ -539,13 +548,13 @@ void __osd_Volume( vlc_object_t *p_this )
vlc_value_t lockval;
int i_volume = 0;
int i_steps = 0;
if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
{
msg_Err( p_this, "OSD menu volume update failed" );
return;
}
var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
vlc_mutex_lock( lockval.p_address );
......@@ -556,7 +565,8 @@ void __osd_Volume( vlc_object_t *p_this )
{
/* Update the volume state images to match the current volume */
i_volume = config_GetInt( p_this, "volume" );
i_steps = OSD_VOLUME_STEPS( i_volume, p_button->i_ranges );
i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );
msg_Err( p_this, "OSD steps=%d", i_steps );
p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );
osd_UpdateState( p_osd->p_state,
......
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