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 ) ...@@ -756,7 +756,7 @@ static void Run( intf_thread_t *p_intf )
break; break;
} }
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
} /* End of current playlist status */ } /* End of current playlist status */
} }
} }
else if( !strcmp( psz_cmd, "get_time" ) ) else if( !strcmp( psz_cmd, "get_time" ) )
...@@ -860,7 +860,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -860,7 +860,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
p_playlist = NULL; p_playlist = NULL;
} }
var_DelCallback( p_intf->p_vlc, "volume", VolumeChanged, p_intf ); 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, ...@@ -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 ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
intf_thread_t *p_intf = (intf_thread_t*)p_data; intf_thread_t *p_intf = (intf_thread_t*)p_data;
vlc_mutex_lock( &p_intf->p_sys->status_lock ); vlc_mutex_lock( &p_intf->p_sys->status_lock );
msg_rc( STATUS_CHANGE "( audio volume: %d )", newval.i_int ); msg_rc( STATUS_CHANGE "( audio volume: %d )", newval.i_int );
vlc_mutex_unlock( &p_intf->p_sys->status_lock ); 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, ...@@ -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; intf_thread_t *p_intf = (intf_thread_t*)p_data;
playlist_t *p_playlist = NULL; playlist_t *p_playlist = NULL;
input_thread_t *p_input = NULL; input_thread_t *p_input = NULL;
vlc_mutex_lock( &p_intf->p_sys->status_lock ); vlc_mutex_lock( &p_intf->p_sys->status_lock );
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input ) if( p_input )
...@@ -1247,7 +1247,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1247,7 +1247,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
if( p_playlist->p_input ) if( p_playlist->p_input )
{ {
vlc_value_t val; vlc_value_t val;
var_Get( p_playlist->p_input, "rate", &val ); var_Get( p_playlist->p_input, "rate", &val );
if( val.i_int != INPUT_RATE_DEFAULT ) if( val.i_int != INPUT_RATE_DEFAULT )
{ {
...@@ -1718,8 +1718,10 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1718,8 +1718,10 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
audio_volume_t i_volume; audio_volume_t i_volume;
int i_nb_steps = atoi(newval.psz_string); int i_nb_steps = atoi(newval.psz_string);
int i_error = VLC_SUCCESS; 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; i_nb_steps = 1;
} }
......
...@@ -250,7 +250,9 @@ ...@@ -250,7 +250,9 @@
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
audio_volume_t i_volume = (audio_volume_t)[sender intValue]; 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 */ /* Manage volume status */
[o_main manageVolumeSlider]; [o_main manageVolumeSlider];
} }
......
...@@ -1018,11 +1018,12 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1018,11 +1018,12 @@ static VLCMain *_o_sharedMainInstance = nil;
if( p_intf->p_sys->b_volume_update ) if( p_intf->p_sys->b_volume_update )
{ {
NSString *o_text; NSString *o_text;
int i_volume_step = 0;
o_text = [NSString stringWithFormat: _NS("Volume: %d%%"), i_lastShownVolume * 400 / AOUT_VOLUME_MAX]; o_text = [NSString stringWithFormat: _NS("Volume: %d%%"), i_lastShownVolume * 400 / AOUT_VOLUME_MAX];
if( i_lastShownVolume != -1 ) if( i_lastShownVolume != -1 )
[self setScrollField:o_text stopAfter:1000000]; [self setScrollField:o_text stopAfter:1000000];
i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
[o_volumeslider setFloatValue: (float)i_lastShownVolume / AOUT_VOLUME_STEP]; [o_volumeslider setFloatValue: (float)i_lastShownVolume / i_volume_step];
[o_volumeslider setEnabled: TRUE]; [o_volumeslider setEnabled: TRUE];
p_intf->p_sys->b_mute = ( i_lastShownVolume == 0 ); p_intf->p_sys->b_mute = ( i_lastShownVolume == 0 );
p_intf->p_sys->b_volume_update = FALSE; p_intf->p_sys->b_volume_update = FALSE;
......
...@@ -147,10 +147,11 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps, ...@@ -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, aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); 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 = 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 ) if ( i_volume > AOUT_VOLUME_MAX )
{ {
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, ...@@ -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, aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); 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 = 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 ) if ( i_volume < AOUT_VOLUME_MIN )
{ {
i_volume = AOUT_VOLUME_MIN; i_volume = AOUT_VOLUME_MIN;
......
...@@ -124,6 +124,11 @@ static char *ppsz_snap_formats[] = ...@@ -124,6 +124,11 @@ static char *ppsz_snap_formats[] =
#define VOLUME_SAVE_LONGTEXT N_( \ #define VOLUME_SAVE_LONGTEXT N_( \
"This saves the audio output volume when you select mute.") "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_TEXT N_("Audio output frequency (Hz)")
#define AOUT_RATE_LONGTEXT N_( \ #define AOUT_RATE_LONGTEXT N_( \
"You can force the audio output frequency here. Common values are " \ "You can force the audio output frequency here. Common values are " \
...@@ -942,6 +947,9 @@ vlc_module_begin(); ...@@ -942,6 +947,9 @@ vlc_module_begin();
add_integer_with_range( "volume", AOUT_VOLUME_DEFAULT, AOUT_VOLUME_MIN, add_integer_with_range( "volume", AOUT_VOLUME_DEFAULT, AOUT_VOLUME_MIN,
AOUT_VOLUME_MAX, NULL, VOLUME_TEXT, AOUT_VOLUME_MAX, NULL, VOLUME_TEXT,
VOLUME_LONGTEXT, VLC_FALSE ); 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, add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT,
AOUT_RATE_LONGTEXT, VLC_TRUE ); AOUT_RATE_LONGTEXT, VLC_TRUE );
#if !defined( SYS_DARWIN ) #if !defined( SYS_DARWIN )
......
...@@ -33,16 +33,17 @@ ...@@ -33,16 +33,17 @@
#undef OSD_MENU_DEBUG #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 * Local prototypes
*****************************************************************************/ *****************************************************************************/
static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * ); 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 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 *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
{ {
osd_menu_t *p_osd = NULL; osd_menu_t *p_osd = NULL;
...@@ -80,7 +81,7 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) ...@@ -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 */ /* Update the volume state images to match the current volume */
i_volume = config_GetInt( p_this, "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 ); p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );
/* Initialize OSD state */ /* Initialize OSD state */
...@@ -526,6 +527,14 @@ void __osd_MenuDown( vlc_object_t *p_this ) ...@@ -526,6 +527,14 @@ void __osd_MenuDown( vlc_object_t *p_this )
vlc_mutex_unlock( lockval.p_address ); 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 * Display current audio volume bitmap
* *
...@@ -539,13 +548,13 @@ void __osd_Volume( vlc_object_t *p_this ) ...@@ -539,13 +548,13 @@ void __osd_Volume( vlc_object_t *p_this )
vlc_value_t lockval; vlc_value_t lockval;
int i_volume = 0; int i_volume = 0;
int i_steps = 0; int i_steps = 0;
if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL ) if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
{ {
msg_Err( p_this, "OSD menu volume update failed" ); msg_Err( p_this, "OSD menu volume update failed" );
return; return;
} }
var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
...@@ -556,7 +565,8 @@ void __osd_Volume( vlc_object_t *p_this ) ...@@ -556,7 +565,8 @@ void __osd_Volume( vlc_object_t *p_this )
{ {
/* Update the volume state images to match the current volume */ /* Update the volume state images to match the current volume */
i_volume = config_GetInt( p_this, "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 ); p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );
osd_UpdateState( p_osd->p_state, 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