1 /*****************************************************************************
2 * audio_output.h : audio output interface
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: audio_output.h,v 1.57 2002/08/11 23:26:28 massiot Exp $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
25 * audio_sample_format_t
26 *****************************************************************************
27 * This structure defines a format for audio samples.
28 *****************************************************************************/
29 struct audio_sample_format_t
36 #define AOUT_FMT_MU_LAW 0x00000001
37 #define AOUT_FMT_A_LAW 0x00000002
38 #define AOUT_FMT_IMA_ADPCM 0x00000004
39 #define AOUT_FMT_U8 0x00000008
40 #define AOUT_FMT_S16_LE 0x00000010 /* Little endian signed 16 */
41 #define AOUT_FMT_S16_BE 0x00000020 /* Big endian signed 16 */
42 #define AOUT_FMT_S8 0x00000040
43 #define AOUT_FMT_U16_LE 0x00000080 /* Little endian U16 */
44 #define AOUT_FMT_U16_BE 0x00000100 /* Big endian U16 */
45 #define AOUT_FMT_SPDIF 0x00000400 /* S/PDIF hardware support */
46 #define AOUT_FMT_FLOAT32 0x00010000
47 #define AOUT_FMT_FIXED32 0x00020000
48 #define AOUT_FMT_A52 0x00100000
49 #define AOUT_FMT_DTS 0x00200000
51 #define AOUT_FMTS_IDENTICAL( p_first, p_second ) ( \
52 ((p_first)->i_format == (p_second)->i_format) \
53 && ((p_first)->i_rate == (p_second)->i_rate) \
54 && ((p_first)->i_channels == (p_second)->i_channels \
55 || (p_first)->i_channels == -1 || (p_second)->i_channels == -1) )
57 #ifdef WORDS_BIGENDIAN
58 # define AOUT_FMT_S16_NE AOUT_FMT_S16_BE
59 # define AOUT_FMT_U16_NE AOUT_FMT_U16_BE
61 # define AOUT_FMT_S16_NE AOUT_FMT_S16_LE
62 # define AOUT_FMT_U16_NE AOUT_FMT_U16_LE
65 #define AOUT_FMT_IS_SPDIF( p_format ) \
66 ( ((p_format)->i_format == AOUT_FMT_SPDIF) \
67 || ((p_format)->i_format == AOUT_FMT_A52) \
68 || ((p_format)->i_format == AOUT_FMT_DTS) )
70 /* This is heavily borrowed from libmad, by Robert Leslie <rob@mars.org> */
72 * Fixed-point format: 0xABBBBBBB
73 * A == whole part (sign + 3 bits)
74 * B == fractional part (28 bits)
76 * Values are signed two's complement, so the effective range is:
77 * 0x80000000 to 0x7fffffff
78 * -8.0 to +7.9999999962747097015380859375
80 * The smallest representable value is:
81 * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9)
83 * 28 bits of fractional accuracy represent about
84 * 8.6 digits of decimal accuracy.
86 * Fixed-point numbers can be added or subtracted as normal
87 * integers, but multiplication requires shifting the 64-bit result
88 * from 56 fractional bits back to 28 (and rounding.)
90 typedef s32 vlc_fixed_t;
91 #define FIXED32_FRACBITS 28
92 #define FIXED32_MIN ((vlc_fixed_t) -0x80000000L)
93 #define FIXED32_MAX ((vlc_fixed_t) +0x7fffffffL)
94 #define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
98 /*****************************************************************************
99 * aout_buffer_t : audio output buffer
100 *****************************************************************************/
107 mtime_t start_date, end_date;
109 struct aout_buffer_t * p_next;
112 /* Size of a frame for S/PDIF output. */
113 #define AOUT_SPDIF_SIZE 6144
115 /*****************************************************************************
117 *****************************************************************************/
118 /* From audio_output.c : */
119 #define aout_NewInstance(a) __aout_NewInstance(VLC_OBJECT(a))
120 VLC_EXPORT( aout_instance_t *, __aout_NewInstance, ( vlc_object_t * ) );
121 VLC_EXPORT( void, aout_DeleteInstance, ( aout_instance_t * ) );
122 VLC_EXPORT( aout_buffer_t *, aout_BufferNew, ( aout_instance_t *, aout_input_t *, size_t ) );
123 VLC_EXPORT( void, aout_BufferDelete, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
124 VLC_EXPORT( void, aout_BufferPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
125 VLC_EXPORT( int, aout_FormatTo, ( audio_sample_format_t * p_format, int ) );
126 #define aout_FormatToByterate(a,b) aout_FormatTo(a,b)
127 #define aout_FormatToSize(a,b) aout_FormatTo(a,b)
130 #define aout_InputNew(a,b,c) __aout_InputNew(VLC_OBJECT(a),b,c)
131 VLC_EXPORT( aout_input_t *, __aout_InputNew, ( vlc_object_t *, aout_instance_t **, audio_sample_format_t * ) );
132 VLC_EXPORT( void, aout_InputDelete, ( aout_instance_t *, aout_input_t * ) );
134 /* From output.c : */
135 VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t ) );