686959e87e
* qatar/master: doxygen: Consistently use '@' instead of '\' for Doxygen markup. Use av_printf_format to check the usage of printf style functions Add av_printf_format, for marking printf style format strings and their parameters ARM: enable thumb for Cortex-M* CPUs nsvdec: Propagate error values instead of returning 0 in nsv_read_header(). build: remove SRC_PATH_BARE variable build: move basic rules and variables to main Makefile build: move special targets to end of main Makefile lavdev: improve feedback in case of invalid frame rate/size vfwcap: prefer "framerate_q" over "fps" in vfw_read_header() v4l2: prefer "framerate_q" over "fps" in v4l2_set_parameters() fbdev: prefer "framerate_q" over "fps" in device context bktr: prefer "framerate" over "fps" for grab_read_header() ALSA: implement channel layout for playback. alsa: support unsigned variants of already supported signed formats. alsa: add support for more formats. ARM: allow building in Thumb2 mode Conflicts: common.mak doc/APIchanges libavcodec/vdpau.h libavdevice/alsa-audio-common.c libavdevice/fbdev.c libavdevice/libdc1394.c libavutil/avutil.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
97 lines
3.0 KiB
C
97 lines
3.0 KiB
C
/*
|
|
* ALSA input and output
|
|
* Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
|
|
* Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* ALSA input and output: definitions and structures
|
|
* @author Luca Abeni ( lucabe72 email it )
|
|
* @author Benoit Fouet ( benoit fouet free fr )
|
|
*/
|
|
|
|
#ifndef AVDEVICE_ALSA_AUDIO_H
|
|
#define AVDEVICE_ALSA_AUDIO_H
|
|
|
|
#include <alsa/asoundlib.h>
|
|
#include "config.h"
|
|
#include "libavutil/log.h"
|
|
#include "avdevice.h"
|
|
|
|
/* XXX: we make the assumption that the soundcard accepts this format */
|
|
/* XXX: find better solution with "preinit" method, needed also in
|
|
other formats */
|
|
#define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE)
|
|
|
|
typedef void (*ff_reorder_func)(const void *, void *, int);
|
|
|
|
typedef struct {
|
|
AVClass *class;
|
|
snd_pcm_t *h;
|
|
int frame_size; ///< preferred size for reads and writes
|
|
int period_size; ///< bytes per sample * channels
|
|
int sample_rate; ///< sample rate set by user
|
|
int channels; ///< number of channels set by user
|
|
void (*reorder_func)(const void *, void *, int);
|
|
void *reorder_buf;
|
|
int reorder_buf_size; ///< in frames
|
|
} AlsaData;
|
|
|
|
/**
|
|
* Open an ALSA PCM.
|
|
*
|
|
* @param s media file handle
|
|
* @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
|
|
* @param sample_rate in: requested sample rate;
|
|
* out: actually selected sample rate
|
|
* @param channels number of channels
|
|
* @param codec_id in: requested CodecID or CODEC_ID_NONE;
|
|
* out: actually selected CodecID, changed only if
|
|
* CODEC_ID_NONE was requested
|
|
*
|
|
* @return 0 if OK, AVERROR_xxx on error
|
|
*/
|
|
int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode,
|
|
unsigned int *sample_rate,
|
|
int channels, enum CodecID *codec_id);
|
|
|
|
/**
|
|
* Close the ALSA PCM.
|
|
*
|
|
* @param s1 media file handle
|
|
*
|
|
* @return 0
|
|
*/
|
|
int ff_alsa_close(AVFormatContext *s1);
|
|
|
|
/**
|
|
* Try to recover from ALSA buffer underrun.
|
|
*
|
|
* @param s1 media file handle
|
|
* @param err error code reported by the previous ALSA call
|
|
*
|
|
* @return 0 if OK, AVERROR_xxx on error
|
|
*/
|
|
int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
|
|
|
|
int ff_alsa_extend_reorder_buf(AlsaData *s, int size);
|
|
|
|
#endif /* AVDEVICE_ALSA_AUDIO_H */
|