* Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
* Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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,
+ * Libav 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
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
- * @file libavdevice/alsa-audio-enc.c
+ * @file
* ALSA input and output: output
* @author Luca Abeni ( lucabe72 email it )
* @author Benoit Fouet ( benoit fouet free fr )
* which gives a low latency suitable for real-time playback.
*/
-#include "libavformat/avformat.h"
#include <alsa/asoundlib.h>
+#include "libavutil/internal.h"
+
+#include "libavformat/avformat.h"
+
#include "alsa-audio.h"
static av_cold int audio_write_header(AVFormatContext *s1)
AlsaData *s = s1->priv_data;
AVStream *st;
unsigned int sample_rate;
- enum CodecID codec_id;
+ enum AVCodecID codec_id;
int res;
st = s1->streams[0];
int size = pkt->size;
uint8_t *buf = pkt->data;
- while((res = snd_pcm_writei(s->h, buf, size / s->frame_size)) < 0) {
+ size /= s->frame_size;
+ if (s->reorder_func) {
+ if (size > s->reorder_buf_size)
+ if (ff_alsa_extend_reorder_buf(s, size))
+ return AVERROR(ENOMEM);
+ s->reorder_func(buf, s->reorder_buf, size);
+ buf = s->reorder_buf;
+ }
+ while ((res = snd_pcm_writei(s->h, buf, size)) < 0) {
if (res == -EAGAIN) {
return AVERROR(EAGAIN);
return 0;
}
-AVOutputFormat alsa_muxer = {
- "alsa",
- NULL_IF_CONFIG_SMALL("ALSA audio output"),
- "",
- "",
- sizeof(AlsaData),
- DEFAULT_CODEC_ID,
- CODEC_ID_NONE,
- audio_write_header,
- audio_write_packet,
- ff_alsa_close,
- .flags = AVFMT_NOFILE,
+AVOutputFormat ff_alsa_muxer = {
+ .name = "alsa",
+ .long_name = NULL_IF_CONFIG_SMALL("ALSA audio output"),
+ .priv_data_size = sizeof(AlsaData),
+ .audio_codec = DEFAULT_CODEC_ID,
+ .video_codec = AV_CODEC_ID_NONE,
+ .write_header = audio_write_header,
+ .write_packet = audio_write_packet,
+ .write_trailer = ff_alsa_close,
+ .flags = AVFMT_NOFILE,
};