libavdevice/alsa-audio.h
Go to the documentation of this file.
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 "timefilter.h"
00037 #include "avdevice.h"
00038 
00039 /* XXX: we make the assumption that the soundcard accepts this format */
00040 /* XXX: find better solution with "preinit" method, needed also in
00041         other formats */
00042 #define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE)
00043 
00044 typedef void (*ff_reorder_func)(const void *, void *, int);
00045 
00046 #define ALSA_BUFFER_SIZE_MAX 65536
00047 
00048 typedef struct {
00049     AVClass *class;
00050     snd_pcm_t *h;
00051     int frame_size;  
00052     int period_size; 
00053     int sample_rate; 
00054     int channels;    
00055     TimeFilter *timefilter;
00056     void (*reorder_func)(const void *, void *, int);
00057     void *reorder_buf;
00058     int reorder_buf_size; 
00059 } AlsaData;
00060 
00075 int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode,
00076                  unsigned int *sample_rate,
00077                  int channels, enum CodecID *codec_id);
00078 
00086 int ff_alsa_close(AVFormatContext *s1);
00087 
00096 int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
00097 
00098 int ff_alsa_extend_reorder_buf(AlsaData *s, int size);
00099 
00100 #endif /* AVDEVICE_ALSA_AUDIO_H */