]> git.sesse.net Git - vlc/blobdiff - src/audio_output/intf.c
* src/audio_output/intf.c: aout_VolumeGet() needs to call pf_volume_get() if it wants...
[vlc] / src / audio_output / intf.c
index d6fbe35d6227b9c32c0b7647740607702ee98fae..bbfe23a5272c4bcdc815ed34dd889e9e1ed75501 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * intf.c : audio output API towards the interface modules
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: intf.c,v 1.19 2003/10/30 22:34:48 hartman Exp $
+ * Copyright (C) 2002-2004 VideoLAN
+ * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  *****************************************************************************/
 int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
 {
-    int i;
+    int i_volume, i_result = 0;
+    aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
+                                                FIND_ANYWHERE );
 
-    i = config_GetInt( p_object, "volume" );
-    if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
+    i_volume = config_GetInt( p_object, "volume" );
+    if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i_volume;
 
-    return 0;
+    if ( p_aout == NULL ) return 0;
+
+    vlc_mutex_lock( &p_aout->mixer_lock );
+    if ( !p_aout->mixer.b_error )
+    {
+        i_result = p_aout->output.pf_volume_get( p_aout, pi_volume );
+    }
+    vlc_mutex_unlock( &p_aout->mixer_lock );
+
+    vlc_object_release( p_aout );
+    return i_result;
 }
 
 /*****************************************************************************
@@ -144,7 +156,8 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
         i = AOUT_VOLUME_MAX;
     }
     config_PutInt( p_object, "volume", i );
-    config_PutInt( p_object, "saved-volume", i );
+    var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
+    var_SetInteger( p_object->p_libvlc, "saved-volume" , i );
     if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
 
     if ( p_aout == NULL ) return 0;
@@ -180,7 +193,8 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
         i = AOUT_VOLUME_MIN;
     }
     config_PutInt( p_object, "volume", i );
-    config_PutInt( p_object, "saved-volume", i );
+    var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
+    var_SetInteger( p_object->p_libvlc, "saved-volume", i );
     if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
 
     if ( p_aout == NULL ) return 0;
@@ -212,13 +226,16 @@ int __aout_VolumeMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
     {
         /* Mute */
         i_result = aout_VolumeSet( p_object, AOUT_VOLUME_MIN );
-        config_PutInt( p_object, "saved-volume", (int)i_volume );
+        var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
+        var_SetInteger( p_object->p_libvlc, "saved-volume", (int)i_volume );
         if ( pi_volume != NULL ) *pi_volume = AOUT_VOLUME_MIN;
     }
     else
     {
         /* Un-mute */
-        i_volume = (audio_volume_t)config_GetInt( p_object, "saved-volume" );
+        var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
+        i_volume = (audio_volume_t)var_GetInteger( p_object->p_libvlc,
+                                                   "saved-volume" );
         i_result = aout_VolumeSet( p_object, i_volume );
         if ( pi_volume != NULL ) *pi_volume = i_volume;
     }