]> git.sesse.net Git - vlc/blob - src/audio_output/aout_internal.h
10c790b383b8b1989aa71c0c7500230bb2882e51
[vlc] / src / audio_output / aout_internal.h
1 /*****************************************************************************
2  * aout_internal.h : internal defines for audio output
3  *****************************************************************************
4  * Copyright (C) 2002 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 #ifndef LIBVLC_AOUT_INTERNAL_H
25 # define LIBVLC_AOUT_INTERNAL_H 1
26
27 # include <vlc_atomic.h>
28
29 /* Max input rate factor (1/4 -> 4) */
30 # define AOUT_MAX_INPUT_RATE (4)
31
32 enum {
33     AOUT_RESAMPLING_NONE=0,
34     AOUT_RESAMPLING_UP,
35     AOUT_RESAMPLING_DOWN
36 };
37
38 struct aout_request_vout
39 {
40     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
41                                                video_format_t *, bool );
42     void *p_private;
43 };
44
45 typedef struct aout_volume aout_volume_t;
46 typedef struct aout_dev aout_dev_t;
47
48 typedef struct
49 {
50     vlc_mutex_t lock;
51     module_t *module; /**< Output plugin (or NULL if inactive) */
52     aout_filters_t *filters;
53     aout_volume_t *volume;
54
55     struct
56     {
57         vlc_mutex_t lock;
58         char *device;
59         float volume;
60         signed char mute;
61     } req;
62
63     struct
64     {
65         vlc_mutex_t lock;
66         aout_dev_t *list;
67         unsigned count;
68     } dev;
69
70     struct
71     {
72         mtime_t end; /**< Last seen PTS */
73         unsigned resamp_start_drift; /**< Resampler drift absolute value */
74         int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
75         bool discontinuity;
76     } sync;
77
78     audio_sample_format_t input_format;
79     audio_sample_format_t mixer_format;
80
81     aout_request_vout_t request_vout;
82
83     atomic_uint buffers_lost;
84     atomic_uchar restart;
85 } aout_owner_t;
86
87 typedef struct
88 {
89     audio_output_t output;
90     aout_owner_t   owner;
91 } aout_instance_t;
92
93 static inline aout_owner_t *aout_owner (audio_output_t *aout)
94 {
95     return &((aout_instance_t *)aout)->owner;
96 }
97
98 /****************************************************************************
99  * Prototypes
100  *****************************************************************************/
101
102 /* From mixer.c : */
103 aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
104 #define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
105 int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t);
106 void aout_volume_SetVolume(aout_volume_t *, float);
107 int aout_volume_Amplify(aout_volume_t *, block_t *);
108 void aout_volume_Delete(aout_volume_t *);
109
110
111 /* From output.c : */
112 audio_output_t *aout_New (vlc_object_t *);
113 #define aout_New(a) aout_New(VLC_OBJECT(a))
114 void aout_Destroy (audio_output_t *);
115
116 int aout_OutputNew(audio_output_t *, audio_sample_format_t *);
117 int aout_OutputTimeGet(audio_output_t *, mtime_t *);
118 void aout_OutputPlay(audio_output_t *, block_t *);
119 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
120 void aout_OutputFlush( audio_output_t * p_aout, bool );
121 void aout_OutputDelete( audio_output_t * p_aout );
122 void aout_OutputLock(audio_output_t *);
123 void aout_OutputUnlock(audio_output_t *);
124
125
126 /* From common.c : */
127 void aout_FormatsPrint(vlc_object_t *, const char *,
128                        const audio_sample_format_t *,
129                        const audio_sample_format_t *);
130 #define aout_FormatsPrint(o, t, a, b) \
131         aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
132 bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
133                               const char *var, const char *name, bool b_add );
134
135 /* From dec.c */
136 int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
137                 const audio_replay_gain_t *, const aout_request_vout_t *);
138 void aout_DecDelete(audio_output_t *);
139 int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
140 int aout_DecGetResetLost(audio_output_t *);
141 void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
142 void aout_DecFlush(audio_output_t *);
143 bool aout_DecIsEmpty(audio_output_t *);
144 void aout_RequestRestart (audio_output_t *, unsigned);
145
146 static inline void aout_InputRequestRestart(audio_output_t *aout)
147 {
148     aout_RequestRestart(aout, AOUT_RESTART_FILTERS);
149 }
150
151 #endif /* !LIBVLC_AOUT_INTERNAL_H */