On Tue, 24 May 2011 12:16:43 +0200, Stefano Sabatini 
<[email protected]> wrote:
> On date Tuesday 2011-05-24 07:35:01 +0200, Anton Khirnov encoded:
> > ---
> >  libavdevice/sndio_common.h |    2 ++
> >  libavdevice/sndio_dec.c    |   24 +++++++++++++++++++-----
> >  2 files changed, 21 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavdevice/sndio_common.h b/libavdevice/sndio_common.h
> > index 41c984b..e23b96d 100644
> > --- a/libavdevice/sndio_common.h
> > +++ b/libavdevice/sndio_common.h
> > @@ -26,8 +26,10 @@
> >  #include <sndio.h>
> >  
> >  #include "libavformat/avformat.h"
> > +#include "libavutil/log.h"
> >  
> >  typedef struct {
> > +    AVClass *class;
> >      struct sio_hdl *hdl;
> >      enum CodecID codec_id;
> >      int64_t hwpos;
> > diff --git a/libavdevice/sndio_dec.c b/libavdevice/sndio_dec.c
> > index ff2adeb..b4fc9a6 100644
> > --- a/libavdevice/sndio_dec.c
> > +++ b/libavdevice/sndio_dec.c
> > @@ -23,6 +23,7 @@
> >  #include <sndio.h>
> >  
> >  #include "libavformat/avformat.h"
> > +#include "libavutil/opt.h"
> >  
> >  #include "sndio_common.h"
> >  
> > @@ -33,16 +34,15 @@ static av_cold int audio_read_header(AVFormatContext 
> > *s1,
> >      AVStream *st;
> >      int ret;
> >  
> > -    if (ap->sample_rate <= 0 || ap->channels <= 0)
> > -        return AVERROR(EINVAL);
> > +    if (ap->sample_rate > 0)
> > +        s->sample_rate = ap->sample_rate;
> > +    if (ap->channels > 0)
> > +        s->channels = ap->channels;
> >  
> >      st = av_new_stream(s1, 0);
> >      if (!st)
> >          return AVERROR(ENOMEM);
> >  
> > -    s->sample_rate = ap->sample_rate;
> > -    s->channels    = ap->channels;
> > -
> >      ret = ff_sndio_open(s1, 0, s1->filename);
> >      if (ret < 0)
> >          return ret;
> > @@ -97,6 +97,19 @@ static av_cold int audio_read_close(AVFormatContext *s1)
> >      return 0;
> >  }
> >  
> > +static const AVOption options[] = {
> 
> > +    { "sample_rate", "", offsetof(SndioData, sample_rate), 
> > FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
> > +    { "channels",    "", offsetof(SndioData, channels),    
> > FF_OPT_TYPE_INT, {.dbl = 2},     1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
> 
> From where these defaults come from?

http://tvtropes.org/pmwiki/pmwiki.php/Main/AssPull
I made them up. They look pretty sane to me, surely better than no
defaults at all. Suggestions for better defaults welcome.

--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to