aout_internal.h 5.57 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
/*****************************************************************************
 * aout_internal.h : internal defines for audio output
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
4
 * Copyright (C) 2002 VLC authors and VideoLAN
zorglub's avatar
zorglub committed
5
6
7
8
 * $Id$
 *
 * Authors: Christophe Massiot <massiot@via.ecp.fr>
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
9
10
11
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
zorglub's avatar
zorglub committed
12
13
14
15
 * (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
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
16
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
zorglub's avatar
zorglub committed
18
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
19
20
21
 * You should have received a copy of the GNU Lesser 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.
zorglub's avatar
zorglub committed
22
23
 *****************************************************************************/

24
25
#ifndef LIBVLC_AOUT_INTERNAL_H
# define LIBVLC_AOUT_INTERNAL_H 1
26

27
28
# include <vlc_atomic.h>

29
30
31
/* Max input rate factor (1/4 -> 4) */
# define AOUT_MAX_INPUT_RATE (4)

32
33
# define AOUT_MAX_FILTERS 10

34
35
36
37
38
39
enum {
    AOUT_RESAMPLING_NONE=0,
    AOUT_RESAMPLING_UP,
    AOUT_RESAMPLING_DOWN
};

40
41
42
43
44
45
46
typedef struct
{
    struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
                                               video_format_t *, bool );
    void *p_private;
} aout_request_vout_t;

47
48
typedef struct aout_volume aout_volume_t;

49
50
typedef struct
{
51
    vlc_mutex_t lock;
52
    module_t *module; /**< Output plugin (or NULL if inactive) */
53
    aout_volume_t *volume;
54

55
56
    struct
    {
57
58
59
60
        mtime_t end; /**< Last seen PTS */
        unsigned resamp_start_drift; /**< Resampler drift absolute value */
        int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
        bool discontinuity;
61
62
    } sync;

63
    audio_sample_format_t input_format;
64
    audio_sample_format_t mixer_format;
65

66
67
68
    filter_t *rate_filter; /**< The filter adjusting samples count
        (either the scaletempo filter or a resampler) */
    filter_t *resampler; /**< The resampler */
69
70
    int resampling; /**< Current resampling (Hz) */
    unsigned nb_filters;
71
72
73
74
75
    filter_t *filters[AOUT_MAX_FILTERS]; /**< Configured user filters
        (e.g. equalization) and their conversions */

    aout_request_vout_t request_vout;
    bool recycle_vout;
76

77
    atomic_uint buffers_lost;
78
    vlc_atomic_t restart;
79
80
81
82
83
84
85
86
87
88
89
90
} aout_owner_t;

typedef struct
{
    audio_output_t output;
    aout_owner_t   owner;
} aout_instance_t;

static inline aout_owner_t *aout_owner (audio_output_t *aout)
{
    return &((aout_instance_t *)aout)->owner;
}
91

zorglub's avatar
zorglub committed
92
93
94
/****************************************************************************
 * Prototypes
 *****************************************************************************/
95

zorglub's avatar
zorglub committed
96
/* From filters.c : */
97
98
int aout_FiltersNew(audio_output_t *, const audio_sample_format_t *,
                   const audio_sample_format_t *, const aout_request_vout_t *);
99
void aout_FiltersDelete(audio_output_t *);
100
101
bool aout_FiltersAdjustResampling(audio_output_t *, int);
block_t *aout_FiltersPlay(audio_output_t *, block_t *, int rate);
102

zorglub's avatar
zorglub committed
103
/* From mixer.c : */
104
105
106
107
108
109
aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
#define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t);
void aout_volume_SetVolume(aout_volume_t *, float);
int aout_volume_Amplify(aout_volume_t *, block_t *);
void aout_volume_Delete(aout_volume_t *);
110

111

zorglub's avatar
zorglub committed
112
/* From output.c : */
113
114
115
116
audio_output_t *aout_New (vlc_object_t *);
#define aout_New(a) aout_New(VLC_OBJECT(a))
void aout_Destroy (audio_output_t *);

117
int aout_OutputNew(audio_output_t *, audio_sample_format_t *);
118
119
int aout_OutputTimeGet(audio_output_t *, mtime_t *);
void aout_OutputPlay(audio_output_t *, block_t *);
120
void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
121
void aout_OutputFlush( audio_output_t * p_aout, bool );
122
void aout_OutputDelete( audio_output_t * p_aout );
zorglub's avatar
zorglub committed
123
124
125


/* From common.c : */
126
vlc_fourcc_t aout_NativeEndian(vlc_fourcc_t);
127
128
129
130
131
void aout_FormatsPrint(vlc_object_t *, const char *,
                       const audio_sample_format_t *,
                       const audio_sample_format_t *);
#define aout_FormatsPrint(o, t, a, b) \
        aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
132
133
bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
                              const char *var, const char *name, bool b_add );
zorglub's avatar
zorglub committed
134
135

/* From dec.c */
136
137
138
139
140
141
142
143
144
145
int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
                const audio_replay_gain_t *, const aout_request_vout_t *);
void aout_DecDelete(audio_output_t *);
block_t *aout_DecNewBuffer(audio_output_t *, size_t);
void aout_DecDeleteBuffer(audio_output_t *, block_t *);
int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
int aout_DecGetResetLost(audio_output_t *);
void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
void aout_DecFlush(audio_output_t *);
bool aout_DecIsEmpty(audio_output_t *);
zorglub's avatar
zorglub committed
146

147
148
void aout_InputRequestRestart(audio_output_t *);

149
/* Audio output locking */
150
static inline void aout_lock( audio_output_t *p_aout )
151
{
152
    vlc_mutex_lock( &aout_owner(p_aout)->lock );
153
154
}

155
static inline void aout_unlock( audio_output_t *p_aout )
156
{
157
    vlc_mutex_unlock( &aout_owner(p_aout)->lock );
158
159
}

160
161
162
#define aout_assert_locked( aout ) \
        vlc_assert_locked( &aout_owner(aout)->lock )

163
#endif /* !LIBVLC_AOUT_INTERNAL_H */