]> git.sesse.net Git - vlc/blob - bindings/libvlcpp/src/audio.cpp
libvlcpp: add an audio class to handle audio functions.
[vlc] / bindings / libvlcpp / src / audio.cpp
1 /*****************************************************************************
2  * audio.cpp: audio part of the media player
3  *****************************************************************************
4  * Copyright (C) 2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "audio.hpp"
25 #include "exception.hpp"
26
27
28 using namespace libvlc;
29
30 Audio::Audio( libvlc_instance_t *libvlcInstance, libvlc_media_player_t *player )
31 {
32     m_libvlcInstance = libvlcInstance;
33     libvlc_retain( m_libvlcInstance );
34
35     m_player = player;
36     libvlc_media_player_retain( m_player );
37 }
38
39 Audio::~Audio()
40 {
41     libvlc_media_player_release( m_player );
42     libvlc_release( m_libvlcInstance );
43 }
44
45 void Audio::toggleMute()
46 {
47     libvlc_audio_toggle_mute( m_libvlcInstance );
48 }
49
50 int Audio::mute()
51 {
52     return libvlc_audio_get_mute( m_libvlcInstance );
53 }
54
55 void Audio::setMute( int mute )
56 {
57     libvlc_audio_set_mute( m_libvlcInstance, mute );
58 }
59
60 int Audio::volume()
61 {
62     return libvlc_audio_get_volume( m_libvlcInstance );
63 }
64
65 void Audio::setVolume( int volume )
66 {
67     Exception ex;
68     libvlc_audio_set_volume( m_libvlcInstance, volume, &ex.ex );
69 }
70
71 int Audio::track()
72 {
73     Exception ex;
74     return libvlc_audio_get_track( m_player, &ex.ex );
75 }
76
77 int Audio::trackCount()
78 {
79     Exception ex;
80     return libvlc_audio_get_track_count( m_player, &ex.ex );
81 }
82
83 void Audio::setTrack( int track )
84 {
85     Exception ex;
86     libvlc_audio_set_track( m_player, track, &ex.ex );
87 }
88