summaryrefslogtreecommitdiff
authorLukasz Marek <lukasz.m.luki@gmail.com>2013-10-27 20:27:39 (GMT)
committer Lukasz Marek <lukasz.m.luki@gmail.com>2013-10-27 20:45:32 (GMT)
commit7f5e75eea94020aaddeda1960186ceee73ca1c36 (patch)
tree7e9451645ca69a92929d37cbdb631ba0ca988c77
parent4fb3aa491b477f819967796f05c4e904d96da76f (diff)
downloadffmpeg-7f5e75eea94020aaddeda1960186ceee73ca1c36.zip
ffmpeg-7f5e75eea94020aaddeda1960186ceee73ca1c36.tar.gz
ffmpeg-7f5e75eea94020aaddeda1960186ceee73ca1c36.tar.bz2
lavd/pulse_audio_enc: more stream validation restrictive
So far pulse device picked up first audio stream and ignored others. It is required to provide exactly one audio stream now. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat
-rw-r--r--libavdevice/pulse_audio_enc.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index 05df05c..e0f23c8 100644
--- a/libavdevice/pulse_audio_enc.c
+++ b/libavdevice/pulse_audio_enc.c
@@ -34,7 +34,6 @@ typedef struct PulseData {
const char *stream_name;
const char *device;
pa_simple *pa;
- unsigned int stream_index;
int64_t timestamp;
} PulseData;
@@ -43,23 +42,15 @@ static av_cold int pulse_write_header(AVFormatContext *h)
PulseData *s = h->priv_data;
AVStream *st = NULL;
int ret;
- unsigned int i;
pa_sample_spec ss;
pa_buffer_attr attr = { -1, -1, -1, -1, -1 };
const char *stream_name = s->stream_name;
- for (i = 0; i < h->nb_streams; i++) {
- if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- st = h->streams[i];
- s->stream_index = i;
- break;
- }
- }
-
- if (!st) {
- av_log(s, AV_LOG_ERROR, "No audio stream found.\n");
+ if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ av_log(s, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
return AVERROR(EINVAL);
}
+ st = h->streams[0];
if (!stream_name) {
if (h->filename[0])
@@ -114,16 +105,13 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
return 0;
}
- if (s->stream_index != pkt->stream_index)
- return 0;
-
if (pkt->dts != AV_NOPTS_VALUE)
s->timestamp = pkt->dts;
if (pkt->duration) {
s->timestamp += pkt->duration;;
} else {
- AVStream *st = h->streams[s->stream_index];
+ AVStream *st = h->streams[0];
AVCodecContext *codec_ctx = st->codec;
AVRational r = { 1, codec_ctx->sample_rate };
int64_t samples = pkt->size / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->channels);