]> git.sesse.net Git - vlc/blob - src/audio_output/intf.c
aout: move aout_ChannelsRestart()
[vlc] / src / audio_output / intf.c
1 /*****************************************************************************
2  * intf.c : audio output API towards the interface modules
3  *****************************************************************************
4  * Copyright (C) 2002-2007 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_aout_intf.h>
34
35 #include <stdio.h>
36 #include <stdlib.h>                            /* calloc(), malloc(), free() */
37 #include <string.h>
38 #include <math.h>
39
40 #include <vlc_aout.h>
41 #include "aout_internal.h"
42
43 #include <vlc_playlist.h>
44
45 static audio_output_t *findAout (vlc_object_t *obj)
46 {
47     input_thread_t *(*pf_find_input) (vlc_object_t *);
48
49     pf_find_input = var_GetAddress (obj, "find-input-callback");
50     if (unlikely(pf_find_input == NULL))
51         return NULL;
52
53     input_thread_t *p_input = pf_find_input (obj);
54     if (p_input == NULL)
55        return NULL;
56
57     audio_output_t *p_aout = input_GetAout (p_input);
58     vlc_object_release (p_input);
59     return p_aout;
60 }
61 #define findAout(o) findAout(VLC_OBJECT(o))
62
63 #undef aout_VolumeGet
64 /**
65  * Gets the volume of the output device (independent of mute).
66  * \return Current audio volume (0 = silent, 1 = nominal),
67  * or a strictly negative value if undefined.
68  */
69 float aout_VolumeGet (vlc_object_t *obj)
70 {
71     audio_output_t *aout = findAout (obj);
72     if (aout == NULL)
73         return -1.f;
74
75     float volume = aout_OutputVolumeGet (aout);
76     vlc_object_release (aout);
77     return volume;
78 }
79
80 #undef aout_VolumeSet
81 /**
82  * Sets the volume of the output device.
83  * \note The mute status is not changed.
84  */
85 int aout_VolumeSet (vlc_object_t *obj, float vol)
86 {
87     int ret = -1;
88
89     audio_output_t *aout = findAout (obj);
90     if (aout != NULL)
91     {
92         ret = aout_OutputVolumeSet (aout, vol);
93         vlc_object_release (aout);
94     }
95     return ret;
96 }
97
98 #undef aout_MuteGet
99 /**
100  * Gets the output mute status.
101  * \return 0 if not muted, 1 if muted, -1 if undefined.
102  */
103 int aout_MuteGet (vlc_object_t *obj)
104 {
105     audio_output_t *aout = findAout (obj);
106     if (aout == NULL)
107         return -1.f;
108
109     bool mute = aout_OutputMuteGet (aout);
110     vlc_object_release (aout);
111     return mute;
112 }
113
114 #undef aout_MuteSet
115 /**
116  * Sets mute status.
117  */
118 int aout_MuteSet (vlc_object_t *obj, bool mute)
119 {
120     int ret = -1;
121
122     audio_output_t *aout = findAout (obj);
123     if (aout != NULL)
124     {
125         ret = aout_OutputMuteSet (aout, mute);
126         vlc_object_release (aout);
127         if (ret == 0)
128             var_SetBool (obj, "mute", mute);
129     }
130     return ret;
131 }
132
133
134