]> git.sesse.net Git - vlc/commitdiff
libvlc: introduce 'Muted' as a whole state, not as volume 0
authorFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 7 Jan 2010 19:18:29 +0000 (20:18 +0100)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 10 Jan 2010 13:43:15 +0000 (15:43 +0200)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
include/vlc_aout.h
src/audio_output/intf.c
src/libvlc.c
src/libvlccore.sym

index cd3156440e36d356248309bda0dca34aa6f218dc..5025f346a61304118d71fd4213fb6593c1cc70af 100644 (file)
@@ -320,6 +320,8 @@ VLC_EXPORT( int, __aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) );
 VLC_EXPORT( int, __aout_VolumeDown, ( vlc_object_t *, int, audio_volume_t * ) );
 #define aout_ToggleMute(a, b) __aout_ToggleMute(VLC_OBJECT(a), b)
 VLC_EXPORT( int, __aout_ToggleMute, ( vlc_object_t *, audio_volume_t * ) );
+VLC_EXPORT( int, aout_SetMute, ( vlc_object_t *, audio_volume_t *, bool ) );
+VLC_EXPORT( bool, aout_IsMuted, ( vlc_object_t * ) );
 VLC_EXPORT( int, aout_FindAndRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
 VLC_EXPORT( int, aout_ChannelsRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
 
index 3476ad3ce89ad63be192d00f7e923e45ab37e0c6..9dfd0277519d31ad2e8f3402384db1572257f44b 100644 (file)
@@ -132,7 +132,6 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
 int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
                    audio_volume_t * pi_volume )
 {
-
     const int i_volume_step = config_GetInt( p_object->p_libvlc, "volume-step" );
 
     int i_volume = config_GetInt( p_object, "volume" ) +
@@ -166,12 +165,34 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
  * function (muted => 0).
  *****************************************************************************/
 int __aout_ToggleMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
+{
+    return aout_SetMute( p_object, pi_volume, !aout_IsMuted( p_object ) );
+}
+
+/*****************************************************************************
+ * aout_IsMuted : Get the output volume mute status
+ *****************************************************************************/
+bool aout_IsMuted( vlc_object_t * p_object )
+{
+    return (bool)var_GetBool( p_object->p_libvlc, "volume-muted");
+}
+
+/*****************************************************************************
+ * aout_SetMute : Sets mute status
+ *****************************************************************************
+ * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
+ * function (muted => 0).
+ *****************************************************************************/
+int aout_SetMute( vlc_object_t * p_object, audio_volume_t * pi_volume,
+                  bool b_mute )
 {
     int i_result;
     audio_volume_t i_volume;
 
+    var_SetBool( p_object->p_libvlc, "volume-muted", (bool)b_mute );
     i_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
-    if ( i_volume != 0 )
+
+    if ( b_mute )
     {
         /* Mute */
         i_result = aout_VolumeSet( p_object, AOUT_VOLUME_MIN );
@@ -188,7 +209,6 @@ int __aout_ToggleMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
         i_result = aout_VolumeSet( p_object, i_volume );
         if ( pi_volume != NULL ) *pi_volume = i_volume;
     }
-
     return i_result;
 }
 
index 358a298860d980c250e088ef400b69145f2990be..ff6123336d1a25282a4da718c44a6e86656959c6 100644 (file)
@@ -859,6 +859,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /* Create volume callback system. (this variable must be created before
        all interfaces as they can use it) */
     var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
+    var_Create( p_libvlc, "volume-muted", VLC_VAR_BOOL );
 
     psz_modules = var_CreateGetNonEmptyString( p_libvlc, "extraintf" );
     psz_control = var_CreateGetNonEmptyString( p_libvlc, "control" );
index 1a7a372b000acb03803cd141c72f56c1a99cdeda..9656d1a85672395910980548197c9352075584fa 100644 (file)
@@ -25,6 +25,8 @@ aout_OutputNextBuffer
 __aout_VolumeDown
 __aout_VolumeGet
 __aout_ToggleMute
+aout_IsMuted
+aout_SetMute
 aout_VolumeNoneInit
 __aout_VolumeSet
 aout_VolumeSoftInit