X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavdevice%2Foss_audio.c;h=a1f0cbd3d03f9b6e91bb1029f5f35b1e0f6cb2c7;hb=a7d3a51dd1efa3073cc9d419a73f709f784ce267;hp=fc5d3c3dd1000be2bf7c5010918697b86c7983fc;hpb=3788a3c0c03585b0f8180a16d2a15b8e0e033313;p=ffmpeg diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c index fc5d3c3dd10..a1f0cbd3d03 100644 --- a/libavdevice/oss_audio.c +++ b/libavdevice/oss_audio.c @@ -37,12 +37,14 @@ #include #include "libavutil/log.h" +#include "libavutil/opt.h" #include "libavcodec/avcodec.h" -#include "libavformat/avformat.h" +#include "avdevice.h" #define AUDIO_BLOCK_SIZE 4096 typedef struct { + AVClass *class; int fd; int sample_rate; int channels; @@ -78,13 +80,6 @@ static int audio_open(AVFormatContext *s1, int is_output, const char *audio_devi fcntl(audio_fd, F_SETFL, O_NONBLOCK); s->frame_size = AUDIO_BLOCK_SIZE; -#if 0 - tmp = (NB_FRAGMENTS << 16) | FRAGMENT_BITS; - err = ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &tmp); - if (err < 0) { - perror("SNDCTL_DSP_SETFRAGMENT"); - } -#endif /* select format : favour native format */ err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp); @@ -214,15 +209,17 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) AVStream *st; int ret; - if (ap->sample_rate <= 0 || ap->channels <= 0) - return -1; +#if FF_API_FORMAT_PARAMETERS + if (ap->sample_rate > 0) + s->sample_rate = ap->sample_rate; + if (ap->channels > 0) + s->channels = ap->channels; +#endif st = av_new_stream(s1, 0); if (!st) { return AVERROR(ENOMEM); } - s->sample_rate = ap->sample_rate; - s->channels = ap->channels; ret = audio_open(s1, 0, s1->filename); if (ret < 0) { @@ -291,6 +288,19 @@ static int audio_read_close(AVFormatContext *s1) } #if CONFIG_OSS_INDEV +static const AVOption options[] = { + { "sample_rate", "", offsetof(AudioData, sample_rate), FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(AudioData, channels), FF_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass oss_demuxer_class = { + .class_name = "OSS demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_oss_demuxer = { "oss", NULL_IF_CONFIG_SMALL("Open Sound System capture"), @@ -300,6 +310,7 @@ AVInputFormat ff_oss_demuxer = { audio_read_packet, audio_read_close, .flags = AVFMT_NOFILE, + .priv_class = &oss_demuxer_class, }; #endif