[FFmpeg-devel] [PATCH 2/2] lavd/alsa: add stream validation

Lukasz M lukasz.m.luki at gmail.com
Sat Oct 26 03:01:09 CEST 2013


On 26 October 2013 02:40, Timothy Gu <timothygu99 at gmail.com> wrote:

> On Oct 25, 2013 5:39 PM, "Timothy Gu" <timothygu99 at gmail.com> wrote:
> >
> >
> > On Oct 25, 2013 4:40 PM, "Lukasz Marek" <lukasz.m.luki at gmail.com> wrote:
> > >
> > > Don't trust provided streams. Find first audio stream and use it.
> > > Make a warning if more than one.
> > >
> > > Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> > > ---
> > >  libavdevice/alsa-audio-enc.c |   20 +++++++++++++++++---
> > >  libavdevice/alsa-audio.h     |    1 +
> > >  2 files changed, 18 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/libavdevice/alsa-audio-enc.c
> b/libavdevice/alsa-audio-enc.c
> > > index 4d0e17b..1d57462 100644
> > > --- a/libavdevice/alsa-audio-enc.c
> > > +++ b/libavdevice/alsa-audio-enc.c
> > > @@ -51,8 +51,22 @@ static av_cold int
> audio_write_header(AVFormatContext *s1)
> > >      unsigned int sample_rate;
> > >      enum AVCodecID codec_id;
> > >      int res;
> > > +    unsigned int i;
> > > +
> > > +    for (i = 0; i < s1->nb_streams; i++) {
> > > +        if (s1->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
> > > +            st = s1->streams[i];
> > > +            s->index = i;
> > > +        } else {
> > > +            av_log(s1, AV_LOG_WARNING, "More than one audio stream
> found. First one is used.\n");
> > > +            break;
> > > +        }
> > > +    }
> >
> > The logic is wrong here. So if stream[0]->codec->codec_type !=
> AVMEDIA_TYPE_AUDIO,
> > it will report that "More than one audio stream is found".
> > And if stream[1] is audio too, it will overwrite s->index to be 2.
>
> I mean overwrite index to be 1.
>
> Yes, thanks for being observant. Patch attached.
I'd better go to sleep for tonight :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavd-alsa-add-stream-validation.patch
Type: text/x-patch
Size: 2958 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131026/816efb86/attachment.bin>


More information about the ffmpeg-devel mailing list