diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-07-17 08:08:57 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-08-15 19:56:55 +0200 |
commit | a7c93dae55c045499ffb34a84f8d5031ae594cf9 (patch) | |
tree | 38ef2d9f13dac5168b9aa7607befebc0add8b32c /libavdevice/jack_audio.c | |
parent | 0e8696551414d4ea0aab2559f9475d1fe49d08f3 (diff) | |
download | ffmpeg-a7c93dae55c045499ffb34a84f8d5031ae594cf9.tar.gz |
jack: add 'channels' private option.
Get rid of AVFormatParameters usage.
Diffstat (limited to 'libavdevice/jack_audio.c')
-rw-r--r-- | libavdevice/jack_audio.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c index 4af89bda9e..029ace6dc0 100644 --- a/libavdevice/jack_audio.c +++ b/libavdevice/jack_audio.c @@ -26,6 +26,7 @@ #include "libavutil/log.h" #include "libavutil/fifo.h" +#include "libavutil/opt.h" #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavformat/timefilter.h" @@ -36,6 +37,7 @@ #define FIFO_PACKETS_NUM 16 typedef struct { + AVClass *class; jack_client_t * client; int activated; sem_t packet_count; @@ -136,7 +138,7 @@ static int supply_new_packets(JackData *self, AVFormatContext *context) return 0; } -static int start_jack(AVFormatContext *context, AVFormatParameters *params) +static int start_jack(AVFormatContext *context) { JackData *self = context->priv_data; jack_status_t status; @@ -153,7 +155,6 @@ static int start_jack(AVFormatContext *context, AVFormatParameters *params) sem_init(&self->packet_count, 0, 0); self->sample_rate = jack_get_sample_rate(self->client); - self->nports = params->channels; self->ports = av_malloc(self->nports * sizeof(*self->ports)); self->buffer_size = jack_get_buffer_size(self->client); @@ -225,10 +226,7 @@ static int audio_read_header(AVFormatContext *context, AVFormatParameters *param AVStream *stream; int test; - if (params->sample_rate <= 0 || params->channels <= 0) - return -1; - - if ((test = start_jack(context, params))) + if ((test = start_jack(context))) return test; stream = av_new_stream(context, 0); @@ -314,6 +312,19 @@ static int audio_read_close(AVFormatContext *context) return 0; } +#define OFFSET(x) offsetof(JackData, x) +static const AVOption options[] = { + { "channels", "Number of audio channels.", OFFSET(nports), FF_OPT_TYPE_INT, { 2 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass jack_indev_class = { + .class_name = "JACK indev", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_jack_demuxer = { "jack", NULL_IF_CONFIG_SMALL("JACK Audio Connection Kit"), @@ -323,4 +334,5 @@ AVInputFormat ff_jack_demuxer = { audio_read_packet, audio_read_close, .flags = AVFMT_NOFILE, + .priv_class = &jack_indev_class, }; |