From 4de0369e8d6d8d497b3aa61044a152ae91d477a6 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 31 Oct 2010 07:26:40 +0200 Subject: options: move audio_output_channels, audio_output_format to struct --- cfg-common.h | 5 ++--- defaultopts.c | 2 ++ libmpcodecs/ad_dmo.c | 6 ++++-- libmpcodecs/ad_faad.c | 10 +++++++--- libmpcodecs/ad_ffmpeg.c | 2 +- libmpcodecs/ad_internal.h | 1 - libmpcodecs/ad_liba52.c | 5 +++-- libmpcodecs/ad_libdca.c | 11 +++++++---- libmpcodecs/dec_audio.c | 2 -- m_option.h | 1 + mplayer.c | 3 +-- options.h | 2 ++ 12 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cfg-common.h b/cfg-common.h index 1e9871f99b..0ae68d0531 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -37,7 +37,6 @@ extern char * codecs_file; extern int field_dominance; /* from dec_audio, currently used for ac3surround decoder only */ -extern int audio_output_channels; extern int fakemono; /* defined in network.c */ @@ -569,8 +568,8 @@ const m_option_t common_opts[] = { // force video/audio rate: {"fps", &force_fps, CONF_TYPE_DOUBLE, CONF_MIN, 0, 0, NULL}, {"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, NULL}, - {"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 1, 8, NULL}, - {"format", &audio_output_format, CONF_TYPE_AFMT, 0, 0, 0, NULL}, + OPT_INTRANGE("channels", audio_output_channels, 0, 1, 8), + OPT_AUDIOFORMAT("format", audio_output_format, 0), OPT_FLOATRANGE("speed", playback_speed, 0, 0.01, 100.0), // set a-v distance diff --git a/defaultopts.c b/defaultopts.c index 2cfeda063d..f263437d74 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -29,6 +29,8 @@ void set_default_mplayer_options(struct MPOpts *opts) .audio_id = -1, .video_id = -1, .sub_id = -1, + .audio_output_channels = 2, + .audio_output_format = -1, // AF_FORMAT_UNKNOWN .playback_speed = 1., .drc_level = 1., .movie_aspect = -1., diff --git a/libmpcodecs/ad_dmo.c b/libmpcodecs/ad_dmo.c index 1501c21078..714651a7e4 100644 --- a/libmpcodecs/ad_dmo.c +++ b/libmpcodecs/ad_dmo.c @@ -21,6 +21,7 @@ #include #include "config.h" +#include "options.h" #include "mp_msg.h" #include "ad_internal.h" @@ -46,9 +47,10 @@ static int init(sh_audio_t *sh) static int preinit(sh_audio_t *sh_audio) { + struct MPOpts *opts = sh_audio->opts; DMO_AudioDecoder* ds_adec; - int chans=(audio_output_channels==sh_audio->wf->nChannels) ? - audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); + int chans=(opts->audio_output_channels==sh_audio->wf->nChannels) ? + opts->audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans))) { mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll); diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c index 2dc6c1f580..96abaa5a6d 100644 --- a/libmpcodecs/ad_faad.c +++ b/libmpcodecs/ad_faad.c @@ -25,6 +25,7 @@ #include #include "config.h" +#include "options.h" #include "ad_internal.h" #include "libaf/reorder_ch.h" @@ -83,6 +84,7 @@ static int aac_probe(unsigned char *buffer, int len) static int init(sh_audio_t *sh) { + struct MPOpts *opts = sh->opts; unsigned long faac_samplerate; unsigned char faac_channels; int faac_init, pos = 0; @@ -105,7 +107,8 @@ static int init(sh_audio_t *sh) /* XXX: FAAD support FLOAT output, how do we handle * that (FAAD_FMT_FLOAT)? ::atmos */ - if (audio_output_channels <= 2) faac_conf->downMatrix = 1; + if (opts->audio_output_channels <= 2) + faac_conf->downMatrix = 1; switch(sh->samplesize){ case 1: // 8Bit mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n"); @@ -177,7 +180,7 @@ static int init(sh_audio_t *sh) } else { // We have ES DS in codecdata faacDecConfigurationPtr faac_conf = faacDecGetCurrentConfiguration(faac_hdec); - if (audio_output_channels <= 2) { + if (opts->audio_output_channels <= 2) { faac_conf->downMatrix = 1; faacDecSetConfiguration(faac_hdec, faac_conf); } @@ -199,7 +202,8 @@ static int init(sh_audio_t *sh) mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Negotiated samplerate: %ldHz channels: %d\n", faac_samplerate, faac_channels); // 8 channels is aac channel order #7. sh->channels = faac_channels == 7 ? 8 : faac_channels; - if (audio_output_channels <= 2) sh->channels = faac_channels > 1 ? 2 : 1; + if (opts->audio_output_channels <= 2) + sh->channels = faac_channels > 1 ? 2 : 1; sh->samplerate = faac_samplerate; sh->samplesize=2; //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate; diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 7c398af5b0..7d945794b8 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -120,7 +120,7 @@ static int init(sh_audio_t *sh_audio) lavc_context->block_align = sh_audio->wf->nBlockAlign; lavc_context->bits_per_coded_sample = sh_audio->wf->wBitsPerSample; } - lavc_context->request_channels = audio_output_channels; + lavc_context->request_channels = opts->audio_output_channels; lavc_context->codec_tag = sh_audio->format; //FOURCC lavc_context->codec_type = CODEC_TYPE_AUDIO; lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi diff --git a/libmpcodecs/ad_internal.h b/libmpcodecs/ad_internal.h index 2a5dbc43ea..a04d3f6165 100644 --- a/libmpcodecs/ad_internal.h +++ b/libmpcodecs/ad_internal.h @@ -28,7 +28,6 @@ #include "ad.h" -extern int audio_output_channels; static int init(sh_audio_t *sh); static int preinit(sh_audio_t *sh); static void uninit(sh_audio_t *sh); diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c index 0cc282776d..abd6a7ac54 100644 --- a/libmpcodecs/ad_liba52.c +++ b/libmpcodecs/ad_liba52.c @@ -141,10 +141,11 @@ static sample_t dynrng_call (sample_t c, void *data) static int preinit(sh_audio_t *sh) { + struct MPOpts *opts = sh->opts; /* Dolby AC3 audio: */ /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ if (sh->samplesize < 4) sh->samplesize = 4; - sh->audio_out_minsize=audio_output_channels*sh->samplesize*256*6; + sh->audio_out_minsize=opts->audio_output_channels*sh->samplesize*256*6; sh->audio_in_minsize=3840; a52_level = 1.0; return 1; @@ -219,7 +220,7 @@ static int init(sh_audio_t *sh_audio) /* 'a52 cannot upmix' hotfix:*/ a52_printinfo(sh_audio); - sh_audio->channels=audio_output_channels; + sh_audio->channels=opts->audio_output_channels; while(sh_audio->channels>0){ switch(sh_audio->channels){ case 1: a52_flags=A52_MONO; break; diff --git a/libmpcodecs/ad_libdca.c b/libmpcodecs/ad_libdca.c index c167c92490..a550cbb8d7 100644 --- a/libmpcodecs/ad_libdca.c +++ b/libmpcodecs/ad_libdca.c @@ -25,8 +25,9 @@ #include #include #include -#include "config.h" +#include "config.h" +#include "options.h" #include "mp_msg.h" #include "ad_internal.h" @@ -280,8 +281,10 @@ end: static int preinit(sh_audio_t *sh) { + struct MPOpts *opts = sh->opts; + /* 256 = samples per block, 16 = max number of blocks */ - sh->audio_out_minsize = audio_output_channels * sizeof(int16_t) * 256 * 16; + sh->audio_out_minsize = opts->audio_output_channels * sizeof(int16_t) * 256 * 16; sh->audio_in_minsize = DTSBUFFER_SIZE; sh->samplesize=2; @@ -308,8 +311,8 @@ static int init(sh_audio_t *sh) } channels_info(flags); - assert(audio_output_channels >= 1 && audio_output_channels <= 6); - sh->channels = audio_output_channels; + assert(opts->audio_output_channels >= 1 && opts->audio_output_channels <= 6); + sh->channels = opts->audio_output_channels; decoded_bytes = decode_audio(sh, sh->a_buffer, 1, sh->a_buffer_size); if(decoded_bytes > 0) diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c index ade2429dc0..572e06a8a1 100644 --- a/libmpcodecs/dec_audio.c +++ b/libmpcodecs/dec_audio.c @@ -44,8 +44,6 @@ int fakemono = 0; #endif -/* used for ac3surround decoder - set using -channels option */ -int audio_output_channels = 2; af_cfg_t af_cfg = { 1, NULL }; // Configuration for audio filters void afm_help(void) diff --git a/m_option.h b/m_option.h index 41c8eae64f..a4a262f44f 100644 --- a/m_option.h +++ b/m_option.h @@ -530,5 +530,6 @@ m_option_free(const m_option_t* opt,void* dst) { #define OPT_FLOATRANGE(optname, varname, flags, min, max) {optname, NULL, &m_option_type_float, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_STRING(optname, varname, flags) {optname, NULL, &m_option_type_string, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_SETTINGSLIST(optname, varname, flags, objlist) {optname, NULL, &m_option_type_obj_settings_list, flags, 0, 0, objlist, 1, offsetof(struct MPOpts, varname)} +#define OPT_AUDIOFORMAT(optname, varname, flags) {optname, NULL, &m_option_type_afmt, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #endif /* MPLAYER_M_OPTION_H */ diff --git a/mplayer.c b/mplayer.c index 0e5b21ba49..1fda090641 100644 --- a/mplayer.c +++ b/mplayer.c @@ -337,7 +337,6 @@ static int softsleep=0; double force_fps=0; static int force_srate=0; -static int audio_output_format=-1; // AF_FORMAT_UNKNOWN int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode static int play_n_frames=-1; static int play_n_frames_mf=-1; @@ -1774,7 +1773,7 @@ void reinit_audio_chain(struct MPContext *mpctx) current_module="af_preinit"; ao_data.samplerate=force_srate; ao_data.channels=0; - ao_data.format=audio_output_format; + ao_data.format = opts->audio_output_format; // first init to detect best values if(!init_audio_filters(mpctx->sh_audio, // preliminary init // input: diff --git a/options.h b/options.h index 08e75fa6a8..9995dc395b 100644 --- a/options.h +++ b/options.h @@ -41,6 +41,8 @@ typedef struct MPOpts { int sub_id; char *audio_lang; char *sub_lang; + int audio_output_channels; + int audio_output_format; float playback_speed; float drc_level; struct m_obj_settings *vf_settings; -- cgit v1.2.3