]> git.sesse.net Git - vlc/blob - src/playlist/aout.c
dvbpsi: do not print a message if message type is DVBPSI_MSG_NONE
[vlc] / src / playlist / aout.c
1 /*****************************************************************************
2  * aout.c: audio output controls for the VLC playlist
3  *****************************************************************************
4  * Copyright (C) 2002-2012 VLC authors and VideoLAN
5  *
6  * Authors: Christophe Massiot <massiot@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include <vlc_common.h>
28 #include <vlc_aout.h>
29 #include <vlc_playlist.h>
30
31 #include "../audio_output/aout_internal.h"
32 #include "playlist_internal.h"
33
34 audio_output_t *playlist_GetAout(playlist_t *pl)
35 {
36     /* NOTE: it is assumed that the input resource exists. In practice,
37      * the playlist must have been activated. This is automatic when calling
38      * pl_Get(). FIXME: input resources are deleted at deactivation, this can
39      * be too early. */
40     playlist_private_t *sys = pl_priv(pl);
41     return input_resource_HoldAout(sys->p_input_resource);
42 }
43
44 float playlist_VolumeGet (playlist_t *pl)
45 {
46     float volume = -1.f;
47
48     audio_output_t *aout = playlist_GetAout (pl);
49     if (aout != NULL)
50     {
51         volume = aout_VolumeGet (aout);
52         vlc_object_release (aout);
53     }
54     return volume;
55 }
56
57 int playlist_VolumeSet (playlist_t *pl, float vol)
58 {
59     int ret = -1;
60
61     audio_output_t *aout = playlist_GetAout (pl);
62     if (aout != NULL)
63     {
64         ret = aout_VolumeSet (aout, vol);
65         vlc_object_release (aout);
66     }
67     return ret;
68 }
69
70 /**
71  * Raises the volume.
72  * \param value how much to increase (> 0) or decrease (< 0) the volume
73  * \param volp if non-NULL, will contain contain the resulting volume
74  */
75 int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
76 {
77     int ret = -1;
78
79     float delta = value * var_InheritFloat (pl, "volume-step");
80
81     audio_output_t *aout = playlist_GetAout (pl);
82     if (aout != NULL)
83     {
84         float vol = aout_VolumeGet (aout);
85         if (vol >= 0.)
86         {
87             vol += delta / (float)AOUT_VOLUME_DEFAULT;
88             if (vol < 0.)
89                 vol = 0.;
90             if (vol > 2.)
91                 vol = 2.;
92             if (volp != NULL)
93                 *volp = vol;
94             ret = aout_VolumeSet (aout, vol);
95         }
96         vlc_object_release (aout);
97     }
98     return ret;
99 }
100
101 int playlist_MuteGet (playlist_t *pl)
102 {
103     int mute = -1;
104
105     audio_output_t *aout = playlist_GetAout (pl);
106     if (aout != NULL)
107     {
108         mute = aout_MuteGet (aout);
109         vlc_object_release (aout);
110     }
111     return mute;
112 }
113
114 int playlist_MuteSet (playlist_t *pl, bool mute)
115 {
116     int ret = -1;
117
118     audio_output_t *aout = playlist_GetAout (pl);
119     if (aout != NULL)
120     {
121         ret = aout_MuteSet (aout, mute);
122         vlc_object_release (aout);
123     }
124     return ret;
125 }
126
127 void playlist_EnableAudioFilter (playlist_t *pl, const char *name, bool add)
128 {
129     audio_output_t *aout = playlist_GetAout (pl);
130
131     if (aout_ChangeFilterString (VLC_OBJECT(pl), VLC_OBJECT(aout),
132                                  "audio-filter", name, add))
133     {
134         if (aout != NULL)
135             aout_InputRequestRestart (aout);
136     }
137     if (aout != NULL)
138         vlc_object_release (aout);
139 }