]> git.sesse.net Git - vlc/blobdiff - src/osd/osd.c
Reworked OSD Volume handling and display of volumebar. Run make stamp-api to update...
[vlc] / src / osd / osd.c
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