00001 /* 00002 * ALSA input and output 00003 * Copyright (c) 2007 Luca Abeni ( lucabe72 email it ) 00004 * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr ) 00005 * 00006 * This file is part of FFmpeg. 00007 * 00008 * FFmpeg is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * FFmpeg is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00030 #ifndef AVDEVICE_ALSA_AUDIO_H 00031 #define AVDEVICE_ALSA_AUDIO_H 00032 00033 #include <alsa/asoundlib.h> 00034 #include "config.h" 00035 #include "libavutil/log.h" 00036 #include "avdevice.h" 00037 00038 /* XXX: we make the assumption that the soundcard accepts this format */ 00039 /* XXX: find better solution with "preinit" method, needed also in 00040 other formats */ 00041 #define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE) 00042 00043 typedef void (*ff_reorder_func)(const void *, void *, int); 00044 00045 #define ALSA_BUFFER_SIZE_MAX 65536 00046 00047 typedef struct { 00048 AVClass *class; 00049 snd_pcm_t *h; 00050 int frame_size; 00051 int period_size; 00052 ff_reorder_func reorder_func; 00053 void *reorder_buf; 00054 int reorder_buf_size; 00055 int sample_rate; 00056 int channels; 00057 } AlsaData; 00058 00073 int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode, 00074 unsigned int *sample_rate, 00075 int channels, enum CodecID *codec_id); 00076 00084 int ff_alsa_close(AVFormatContext *s1); 00085 00094 int ff_alsa_xrun_recover(AVFormatContext *s1, int err); 00095 00096 int ff_alsa_extend_reorder_buf(AlsaData *s, int size); 00097 00098 #endif /* AVDEVICE_ALSA_AUDIO_H */