libvlc_audio.c 3.18 KB
Newer Older
littlejohn's avatar
littlejohn committed
1
2
3
/*****************************************************************************
 * libvlc_audio.c: New libvlc audio control API
 *****************************************************************************
littlejohn's avatar
littlejohn committed
4
5
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
littlejohn's avatar
littlejohn committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 *
 * 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" );
    }    
}