]> git.sesse.net Git - vlc/commitdiff
Added --volume-step to override AOUT_VOLUME_DEFAULT. This will give an OSD menu ...
authorJean-Paul Saman <jpsaman@videolan.org>
Thu, 18 Aug 2005 16:41:10 +0000 (16:41 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Thu, 18 Aug 2005 16:41:10 +0000 (16:41 +0000)
modules/control/rc.c
modules/gui/macosx/controls.m
modules/gui/macosx/intf.m
src/audio_output/intf.c
src/libvlc.h
src/osd/osd.c

index 548dd00af4a4ec6faa1c297f595ff7cedbf531f1..75f953b6f3392f90958292e3687d919ff7598fce 100644 (file)
@@ -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;
     }
index 6c0cd9c58b1f0aaed22fc8ee2f49c91c1788e907..bdaabfac0ce28707a7c00504a8471ac11a66e285 100644 (file)
 {
     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];
 }
index 4bfcb7a8b1c5a3a6695284107cf084d1bf7354e7..8b808ac1ca5e09a7513eaa0466501f04a156d85a 100644 (file)
@@ -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;
index 844736b1ae2ed349efe89e6e4b2cdf3a29923fab..511a062181a70176172d1dc2da4cf5b6eb5bbdfc 100644 (file)
@@ -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;
index 0721a1f07d4d73808e4f5f2fe204178b04baabc9..e41d8752ff7d2ca0757e68684227ea210c5fc3cb 100644 (file)
@@ -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 )
index 989b7172f25129e0ab465ea628f17f44b6e358e0..f248085073e4f79579ca237e5d2be097a6d42728 100644 (file)
 \r
 #undef OSD_MENU_DEBUG\r
 \r
-/* 3 is a magic number for 32 volume decrease steps */\r
-#define OSD_VOLUME_STEPS(i_volume,i_n) (i_volume/AOUT_VOLUME_STEP) / (AOUT_VOLUME_STEP/(i_n-1))\r
-\r
 /*****************************************************************************\r
  * Local prototypes\r
  *****************************************************************************/\r
 \r
 static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );\r
 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );\r
+static int osd_VolumeStep( vlc_object_t *, int, int );\r
 \r
+/*****************************************************************************\r
+ * OSD menu Funtions\r
+ *****************************************************************************/\r
 osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )\r
 {\r
     osd_menu_t  *p_osd = NULL;\r
@@ -80,7 +81,7 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
 \r
         /* Update the volume state images to match the current volume */\r
         i_volume = config_GetInt( p_this, "volume" );\r
-        i_steps = OSD_VOLUME_STEPS( i_volume, p_osd->p_state->p_volume->i_ranges );\r
+        i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges );\r
         p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );\r
 \r
         /* Initialize OSD state */\r
@@ -526,6 +527,14 @@ void __osd_MenuDown( vlc_object_t *p_this )
     vlc_mutex_unlock( lockval.p_address );\r
 }\r
 \r
+static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )\r
+{\r
+    int i_volume_step = 0;\r
+\r
+    i_volume_step = config_GetInt( p_this->p_vlc, "volume-step" );\r
+    return (i_volume/i_volume_step);\r
+}\r
+\r
 /**\r
  * Display current audio volume bitmap\r
  *\r
@@ -539,13 +548,13 @@ void __osd_Volume( vlc_object_t *p_this )
     vlc_value_t lockval;\r
     int i_volume = 0;\r
     int i_steps = 0;\r
-    \r
+\r
     if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )\r
     {\r
         msg_Err( p_this, "OSD menu volume update failed" );\r
         return;\r
     }\r
-    \r
+\r
     var_Get( p_this->p_libvlc, "osd_mutex", &lockval );\r
     vlc_mutex_lock( lockval.p_address );\r
 \r
@@ -556,7 +565,8 @@ void __osd_Volume( vlc_object_t *p_this )
     {\r
         /* Update the volume state images to match the current volume */\r
         i_volume = config_GetInt( p_this, "volume" );\r
-        i_steps = OSD_VOLUME_STEPS( i_volume, p_button->i_ranges );\r
+        i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );\r
+        msg_Err( p_this, "OSD steps=%d", i_steps );\r
         p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );\r
 \r
         osd_UpdateState( p_osd->p_state,\r