]> git.sesse.net Git - vlc/commitdiff
Reworked OSD Volume handling and display of volumebar. Run make stamp-api to update...
authorJean-Paul Saman <jpsaman@videolan.org>
Sat, 13 Aug 2005 19:26:27 +0000 (19:26 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 13 Aug 2005 19:26:27 +0000 (19:26 +0000)
include/vlc_osd.h
modules/control/rc.c
src/osd/osd.c

index 866ecdc65aad92c361755b4d600bf1d57136318a..5f942c4afda7af2c8f104622352caac0287875fe 100644 (file)
@@ -305,21 +305,14 @@ VLC_EXPORT( void, __osd_MenuDown, ( vlc_object_t * ) );
 #define osd_MenuDown(object) __osd_MenuDown( VLC_OBJECT(object) )\r
 \r
 /**\r
- * Turn Volume Up\r
+ * Display the audio volume bitmap.\r
  *\r
- * Use the OSD menu to turn the audio volume up.\r
+ * Display the correct audio volume bitmap that corresponds to the\r
+ * current Audio Volume setting.\r
  */\r
-VLC_EXPORT( void, __osd_VolumeUp, ( vlc_object_t * ) );\r
+VLC_EXPORT( void, __osd_Volume, ( vlc_object_t * ) );\r
 \r
-/**\r
- * Turn Volume Down\r
- *\r
- * Use the OSD menu to turn the audio volume down.\r
- */\r
-VLC_EXPORT( void, __osd_VolumeDown, ( vlc_object_t * ) );\r
-\r
-#define osd_VolumeUp(object)   __osd_VolumeUp( VLC_OBJECT(object) )\r
-#define osd_VolumeDown(object) __osd_VolumeDown( VLC_OBJECT(object) )\r
+#define osd_Volume(object)     __osd_Volume( VLC_OBJECT(object) )\r
 \r
 /**\r
  * Retrieve a non modifyable pointer to the OSD Menu state\r
index 4a7db821c79efc87b1e0878ccb244e351ff5356b..57a7e88474d995b24685b9b699005efc354f3e62 100644 (file)
@@ -1686,7 +1686,8 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
                 var_Set( p_intf->p_vlc, "key-pressed", keyval );
             }        
             i_error = aout_VolumeSet( p_this, i_volume );
-            msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+            osd_Volume( p_this );
+            msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );            
         }
     }
     else
@@ -1724,14 +1725,13 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
     {
         if ( aout_VolumeUp( p_this, i_nb_steps, &i_volume ) < 0 )
             i_error = VLC_EGENERIC;
-        osd_VolumeUp( p_this );
     }
     else
     {
         if ( aout_VolumeDown( p_this, i_nb_steps, &i_volume ) < 0 )
             i_error = VLC_EGENERIC;
-        osd_VolumeDown( p_this );
     }
+    osd_Volume( p_this );
 
     if ( !i_error ) msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
     return i_error;
index 659b58a6ec91f909078d5b9897c622a54350d789..989b7172f25129e0ab465ea628f17f44b6e358e0 100644 (file)
@@ -33,6 +33,9 @@
 \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
@@ -77,7 +80,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 = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */\r
+        i_steps = OSD_VOLUME_STEPS( 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
@@ -156,6 +159,8 @@ static inline osd_state_t *osd_VolumeStateChange( osd_state_t *p_current, int i_
 {\r
     osd_state_t *p_temp = NULL;\r
     int i;\r
+\r
+    if( i_steps < 0 ) i_steps = 0;\r
     \r
     for( i=0; (i < i_steps) && (p_current != NULL); i++ )\r
     {    \r
@@ -522,12 +527,12 @@ void __osd_MenuDown( vlc_object_t *p_this )
 }\r
 \r
 /**\r
- * Audio volume up\r
+ * Display current audio volume bitmap\r
  *\r
  * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function\r
- * when the audio volume is updated outside the OSD menu command "menu up".\r
+ * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select".\r
  */\r
-void __osd_VolumeUp( vlc_object_t *p_this )\r
+void __osd_Volume( vlc_object_t *p_this )\r
 {\r
     osd_menu_t *p_osd = NULL;\r
     osd_button_t *p_button = NULL;\r
@@ -537,77 +542,24 @@ void __osd_VolumeUp( vlc_object_t *p_this )
     \r
     if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )\r
     {\r
-        msg_Err( p_this, "osd_VolumeUp failed" );\r
+        msg_Err( p_this, "OSD menu volume update failed" );\r
         return;\r
     }\r
     \r
     var_Get( p_this->p_libvlc, "osd_mutex", &lockval );\r
     vlc_mutex_lock( lockval.p_address );\r
 \r
-    /* Update the volume state images to match the current volume */\r
-    i_volume = config_GetInt( p_this, "volume" );\r
-    i_steps = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */\r
-    p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );\r
-    \r
     p_button = p_osd->p_state->p_volume;\r
     if( p_osd->p_state->p_volume ) \r
         p_osd->p_state->p_visible = p_osd->p_state->p_volume;\r
     if( p_button && p_button->b_range )\r
     {\r
-        osd_state_t *p_temp = p_button->p_current_state;\r
-        if( p_temp->p_next )\r
-            p_button->p_current_state = p_temp->p_next;\r
-        \r
-        osd_UpdateState( p_osd->p_state, \r
-                p_button->i_x, p_button->i_y,\r
-                p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,\r
-                p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,\r
-                p_button->p_current_state->p_pic );\r
-        osd_SetMenuUpdate( p_osd, VLC_TRUE );\r
-        osd_SetMenuVisible( p_osd, VLC_TRUE );\r
-    }\r
-    vlc_object_release( (vlc_object_t*) p_osd );\r
-    vlc_mutex_unlock( lockval.p_address );\r
-}\r
-\r
-/**\r
- * Audio volume down\r
- *\r
- * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function\r
- * when the audio volume is updated outside the OSD menu command "menu down".\r
- */\r
-void __osd_VolumeDown( vlc_object_t *p_this )\r
-{\r
-    osd_menu_t *p_osd = NULL;\r
-    osd_button_t *p_button = NULL;\r
-    vlc_value_t lockval;\r
-    int i_volume = 0;\r
-    int i_steps = 0;\r
-        \r
-    if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )\r
-    {\r
-        msg_Err( p_this, "osd_VolumeDown failed" );\r
-        return;\r
-    }\r
-    \r
-    var_Get( p_this->p_libvlc, "osd_mutex", &lockval );\r
-    vlc_mutex_lock( lockval.p_address );\r
-\r
-    /* Update the volume state images to match the current volume */\r
-    i_volume = config_GetInt( p_this, "volume" );\r
-    i_steps = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */\r
-    p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );\r
-\r
-    p_button = p_osd->p_state->p_volume;\r
-    if( p_osd->p_state->p_volume ) \r
-        p_osd->p_state->p_visible = p_osd->p_state->p_volume;            \r
-    if( p_button && p_button->b_range )\r
-    {\r
-        osd_state_t *p_temp = p_button->p_current_state;\r
-        if( p_temp && p_temp->p_prev )\r
-            p_button->p_current_state = p_temp->p_prev;\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
+        p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );\r
 \r
-        osd_UpdateState( p_osd->p_state, \r
+        osd_UpdateState( p_osd->p_state,\r
                 p_button->i_x, p_button->i_y,\r
                 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,\r
                 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,\r