]> git.sesse.net Git - vlc/commitdiff
LibVLC basic audio control API
authorFilippo Carone <littlejohn@videolan.org>
Thu, 23 Feb 2006 17:32:49 +0000 (17:32 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Thu, 23 Feb 2006 17:32:49 +0000 (17:32 +0000)
src/Makefile.am
src/control/libvlc_audio.c [new file with mode: 0644]

index 855022f5992718760f72a9f92943619740eb8085..a18e6841ee08d3f82ccdc9de2397b56d43277c6f 100644 (file)
@@ -321,6 +321,7 @@ SOURCES_libvlc_common = \
        control/libvlc_vlm.c \
        control/libvlc_input.c \
        control/libvlc_video.c \
+       control/libvlc_audio.c \
        control/mediacontrol_core.c \
        control/mediacontrol_util.c \
        control/mediacontrol_audio_video.c \
diff --git a/src/control/libvlc_audio.c b/src/control/libvlc_audio.c
new file mode 100644 (file)
index 0000000..b898318
--- /dev/null
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * libvlc_audio.c: New libvlc audio control API
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ *
+ * Authors: Filippo Carone <filippo@carone.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <audio_output.h> /* for audio_volume_t, AOUT_VOLUME_MAX */
+#include <vlc/intf.h>
+
+/*****************************************************************************
+ * libvlc_audio_get_mute : Get the volume state, true if muted
+ *****************************************************************************/
+vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception ) 
+{
+    /*
+     * If the volume level is 0, then the channel is muted
+     */
+    audio_volume_t i_volume;
+
+    i_volume = libvlc_audio_volume_get(p_instance, p_exception);
+    if ( i_volume == 0 )
+        return VLC_TRUE;
+
+    return VLC_FALSE;
+}
+
+
+void libvlc_audio_set_mute( libvlc_instance_t *p_instance, vlc_bool_t status, libvlc_exception_t *p_exception ) 
+{
+    if ( status ) 
+    {
+        aout_VolumeMute( p_instance->p_vlc, NULL);
+    }
+    else 
+    {
+        /* we need to get the volume back from the last registered level */
+        /// \todo FIXME here
+    }   
+}
+
+
+/*****************************************************************************
+ * libvlc_audio_volume_get : Get the current volume (range 0-200 %)
+ *****************************************************************************/
+int libvlc_audio_volume_get( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception ) 
+{
+    audio_volume_t i_volume;
+
+    aout_VolumeGet( p_instance->p_vlc, &i_volume );
+
+    return i_volume*200/AOUT_VOLUME_MAX;
+}
+
+
+/*****************************************************************************
+ * libvlc_audio_volume_set : Set the current volume
+ *****************************************************************************/
+void libvlc_audio_volume_set( libvlc_instance_t *p_instance, int i_volume, libvlc_exception_t *p_exception ) 
+{
+    /** \todo raise exception when volume is not within range */
+    
+    if( i_volume >= 0 && i_volume <= 200 )
+    {
+        i_volume = i_volume * AOUT_VOLUME_MAX / 200;
+        aout_VolumeSet( p_instance->p_vlc, i_volume );
+    }
+    else 
+    {
+        libvlc_exception_raise( p_exception, "Volume out of range" );
+    }    
+}
+