Move/add COSTABLE/SINTABLE macros to dsputil to add extern definitions
[FFMpeg-mirror/lagarith.git] / libavdevice / alsa-audio.h
blob6adde772d298f90c7fccf992cdc873b0e7dea9c5
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 )
6 * This file is part of FFmpeg.
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.
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.
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
23 /**
24 * @file libavdevice/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 )
30 #ifndef AVDEVICE_ALSA_AUDIO_H
31 #define AVDEVICE_ALSA_AUDIO_H
33 #include <alsa/asoundlib.h>
34 #include "config.h"
35 #include "libavformat/avformat.h"
37 /* XXX: we make the assumption that the soundcard accepts this format */
38 /* XXX: find better solution with "preinit" method, needed also in
39 other formats */
40 #if HAVE_BIGENDIAN
41 #define DEFAULT_CODEC_ID CODEC_ID_PCM_S16BE
42 #else
43 #define DEFAULT_CODEC_ID CODEC_ID_PCM_S16LE
44 #endif
46 typedef struct {
47 snd_pcm_t *h;
48 int frame_size; ///< preferred size for reads and writes
49 int period_size; ///< bytes per sample * channels
50 } AlsaData;
52 /**
53 * Opens an ALSA PCM.
55 * @param s media file handle
56 * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
57 * @param sample_rate in: requested sample rate;
58 * out: actually selected sample rate
59 * @param channels number of channels
60 * @param codec_id in: requested CodecID or CODEC_ID_NONE;
61 * out: actually selected CodecID, changed only if
62 * CODEC_ID_NONE was requested
64 * @return 0 if OK, AVERROR_xxx on error
66 int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode,
67 unsigned int *sample_rate,
68 int channels, enum CodecID *codec_id);
70 /**
71 * Closes the ALSA PCM.
73 * @param s1 media file handle
75 * @return 0
77 int ff_alsa_close(AVFormatContext *s1);
79 /**
80 * Tries to recover from ALSA buffer underrun.
82 * @param s1 media file handle
83 * @param err error code reported by the previous ALSA call
85 * @return 0 if OK, AVERROR_xxx on error
87 int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
89 #endif /* AVDEVICE_ALSA_AUDIO_H */