Statistics
| Branch: | Revision:

ffmpeg / libavdevice / alsa-audio.h @ 35fd8122

History | View | Annotate | Download (2.56 KB)

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 alsa-audio.h
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_AUDIO_H
31
#define AVDEVICE_ALSA_AUDIO_H
32

    
33
/* XXX: we make the assumption that the soundcard accepts this format */
34
/* XXX: find better solution with "preinit" method, needed also in
35
        other formats */
36
#ifdef WORDS_BIGENDIAN
37
#define DEFAULT_CODEC_ID CODEC_ID_PCM_S16BE
38
#else
39
#define DEFAULT_CODEC_ID CODEC_ID_PCM_S16LE
40
#endif
41

    
42
typedef struct {
43
    snd_pcm_t *h;
44
    int frame_size;  ///< preferred size for reads and writes
45
    int period_size; ///< bytes per sample * channels
46
} AlsaData;
47

    
48
/**
49
 * Opens an ALSA PCM.
50
 *
51
 * @param s media file handle
52
 * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
53
 * @param sample_rate in: requested sample rate;
54
 *                    out: actually selected sample rate
55
 * @param channels number of channels
56
 * @param codec_id in: requested CodecID or CODEC_ID_NONE;
57
 *                 out: actually selected CodecID, changed only if
58
 *                 CODEC_ID_NONE was requested
59
 *
60
 * @return 0 if OK, AVERROR_xxx on error
61
 */
62
int ff_alsa_open(AVFormatContext *s, int mode, unsigned int *sample_rate,
63
                 int channels, int *codec_id);
64

    
65
/**
66
 * Closes the ALSA PCM.
67
 *
68
 * @param s1 media file handle
69
 *
70
 * @return 0
71
 */
72
int ff_alsa_close(AVFormatContext *s1);
73

    
74
/**
75
 * Tries to recover from ALSA buffer underrun.
76
 *
77
 * @param s1 media file handle
78
 * @param err error code reported by the previous ALSA call
79
 *
80
 * @return 0 if OK, AVERROR_xxx on error
81
 */
82
int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
83

    
84
#endif /* AVDEVICE_ALSA_AUDIO_H */