[vlc-devel] [PATCH 1/3] libvlc: introduce 'Muted' as a whole state, not as volume 0

Francois Cartegnie fcvlcdev at free.fr
Tue Jan 5 18:01:52 CET 2010


---
 include/vlc_aout.h      |    2 ++
 src/audio_output/intf.c |   16 +++++++++++++++-
 src/libvlc.c            |    1 +
 src/libvlccore.sym      |    1 +
 4 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index cd31564..4b3ecb8 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -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 * ) );
+#define aout_IsMuted(a) __aout_IsMuted(VLC_OBJECT(a))
+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 * ) );
 
diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index 3476ad3..b7b24aa 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -169,9 +169,13 @@ int __aout_ToggleMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
 {
     int i_result;
     audio_volume_t i_volume;
+    bool b_muted;
+
+    b_muted = __aout_IsMuted( p_object );
+    var_SetBool( p_object->p_libvlc, "volume-mute-changed", (bool)!b_muted );
 
     i_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
-    if ( i_volume != 0 )
+    if ( !b_muted )
     {
         /* Mute */
         i_result = aout_VolumeSet( p_object, AOUT_VOLUME_MIN );
@@ -192,6 +196,16 @@ int __aout_ToggleMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
     return i_result;
 }
 
+/*****************************************************************************
+ * aout_IsMuted : Get the output volume mute status
+ *****************************************************************************/
+bool __aout_IsMuted( vlc_object_t * p_object )
+{
+    bool b_muted;
+    b_muted = (bool)var_GetBool( p_object->p_libvlc, "volume-mute-changed");
+    return b_muted;
+}
+
 /*
  * The next functions are not supposed to be called by the interface, but
  * are placeholders for software-only scaling.
diff --git a/src/libvlc.c b/src/libvlc.c
index 358a298..f1f567a 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -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-mute-changed", VLC_VAR_BOOL );
 
     psz_modules = var_CreateGetNonEmptyString( p_libvlc, "extraintf" );
     psz_control = var_CreateGetNonEmptyString( p_libvlc, "control" );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 9217093..026036b 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -25,6 +25,7 @@ aout_OutputNextBuffer
 __aout_VolumeDown
 __aout_VolumeGet
 __aout_ToggleMute
+__aout_IsMuted
 aout_VolumeNoneInit
 __aout_VolumeSet
 aout_VolumeSoftInit
-- 
1.6.4.4




More information about the vlc-devel mailing list