1 /*
2 * ALSA input and output
3 * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
4 * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg 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 GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * ALSA input and output: definitions and structures
26 * @author Luca Abeni ( lucabe72 email it )
27 * @author Benoit Fouet ( benoit fouet free fr )
28 */
29
30 #ifndef AVDEVICE_ALSA_H
31 #define AVDEVICE_ALSA_H
32
33 #include <alsa/asoundlib.h>
34 #include "config.h"
39
40 /* XXX: we make the assumption that the soundcard accepts this format */
41 /* XXX: find better solution with "preinit" method, needed also in
42 other formats */
43 #define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)
44
46
47 #define ALSA_BUFFER_SIZE_MAX 131072
48
53 int period_size;
///< preferred size for reads and writes, in frames
55 #if FF_API_ALSA_CHANNELS
56 int channels;
///< number of channels set by user
57 #endif
67
68 /**
69 * Open an ALSA PCM.
70 *
71 * @param s media file handle
72 * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
73 * @param sample_rate in: requested sample rate;
74 * out: actually selected sample rate
75 * @param layout channel layout
76 * @param codec_id in: requested AVCodecID or AV_CODEC_ID_NONE;
77 * out: actually selected AVCodecID, changed only if
78 * AV_CODEC_ID_NONE was requested
79 *
80 * @return 0 if OK, AVERROR_xxx on error
81 */
84 unsigned int *sample_rate,
86
87 /**
88 * Close the ALSA PCM.
89 *
90 * @param s1 media file handle
91 *
92 * @return 0
93 */
95
96 /**
97 * Try to recover from ALSA buffer underrun.
98 *
99 * @param s1 media file handle
100 * @param err error code reported by the previous ALSA call
101 *
102 * @return 0 if OK, AVERROR_xxx on error
103 */
106
109
112
113 #endif /* AVDEVICE_ALSA_H */