Libav
alsa-audio.h
Go to the documentation of this file.
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 Libav.
7  *
8  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
30 #ifndef AVDEVICE_ALSA_AUDIO_H
31 #define AVDEVICE_ALSA_AUDIO_H
32 
33 #include <alsa/asoundlib.h>
34 #include "config.h"
35 #include "libavformat/avformat.h"
36 #include "libavutil/log.h"
37 
38 /* XXX: we make the assumption that the soundcard accepts this format */
39 /* XXX: find better solution with "preinit" method, needed also in
40  other formats */
41 #define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)
42 
43 #define ALSA_BUFFER_SIZE_MAX 32768
44 
45 typedef struct AlsaData {
46  AVClass *class;
47  snd_pcm_t *h;
48  int frame_size;
51  int channels;
52  void (*reorder_func)(const void *, void *, int);
53  void *reorder_buf;
55 } AlsaData;
56 
71 int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode,
72  unsigned int *sample_rate,
73  int channels, enum AVCodecID *codec_id);
74 
83 
92 int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
93 
95 
96 #endif /* AVDEVICE_ALSA_AUDIO_H */
int size
Format I/O context.
Definition: avformat.h:922
int ff_alsa_xrun_recover(AVFormatContext *s1, int err)
Try to recover from ALSA buffer underrun.
int ff_alsa_extend_reorder_buf(AlsaData *s, int size)
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:105
enum AVCodecID codec_id
Definition: mov_chan.c:432
void(* reorder_func)(const void *, void *, int)
Definition: alsa-audio.h:52
int channels
number of channels set by user
Definition: alsa-audio.h:51
int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode, unsigned int *sample_rate, int channels, enum AVCodecID *codec_id)
Open an ALSA PCM.
void * reorder_buf
Definition: alsa-audio.h:53
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
Describe the class of an AVClass context structure.
Definition: log.h:33
int ff_alsa_close(AVFormatContext *s1)
Close the ALSA PCM.
int period_size
bytes per sample * channels
Definition: alsa-audio.h:49
Main libavformat public API header.
snd_pcm_t * h
Definition: alsa-audio.h:47
int frame_size
preferred size for reads and writes
Definition: alsa-audio.h:48
int sample_rate
sample rate set by user
Definition: alsa-audio.h:50
int reorder_buf_size
in frames
Definition: alsa-audio.h:54