From 667c8352f3b0a8dcdaadd2aac6d4588a376e5e52 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Jun 2013 22:57:00 +0200 Subject: core: make options.c compile standalone This also removes the split between "mplayer" and "common" opts (common opts used to be shared between mencoder and mplayer). --- core/mp_core.h | 2 ++ core/mplayer.c | 23 +++++----------- core/options.c | 86 +++++++++++++++++++++++++++++----------------------------- core/options.h | 3 ++ 4 files changed, 55 insertions(+), 59 deletions(-) (limited to 'core') diff --git a/core/mp_core.h b/core/mp_core.h index d7aa42e38d..a327e43822 100644 --- a/core/mp_core.h +++ b/core/mp_core.h @@ -319,6 +319,8 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction); int mp_get_cache_percent(struct MPContext *mpctx); void mp_write_watch_later_conf(struct MPContext *mpctx); +void mp_print_version(int always); + // timeline/tl_matroska.c void build_ordered_chapter_timeline(struct MPContext *mpctx); // timeline/tl_edl.c diff --git a/core/mplayer.c b/core/mplayer.c index 6310a9c271..5c4b582be7 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -141,6 +141,7 @@ #include "stream/stream_dvd.h" #endif +#include "audio/filter/af.h" #include "audio/decode/dec_audio.h" #include "video/decode/dec_video.h" #include "video/mp_image.h" @@ -152,7 +153,7 @@ #include "core/mp_core.h" #include "core/options.h" -static const char help_text[] = _( +const char mp_help_text[] = _( "Usage: mpv [options] [url|path/]filename\n" "\n" "Basic options: (complete list in the man page)\n" @@ -199,8 +200,6 @@ static const char av_desync_help_text[] = _( #include "core/mp_common.h" #include "core/command.h" -#include "core/options.c" - static void reset_subtitles(struct MPContext *mpctx); static void reinit_subs(struct MPContext *mpctx); static struct track *open_external_file(struct MPContext *mpctx, char *filename, @@ -4504,19 +4503,12 @@ static void play_files(struct MPContext *mpctx) } } -static void print_version(int always) +void mp_print_version(int always) { mp_msg(MSGT_CPLAYER, always ? MSGL_INFO : MSGL_V, "%s (C) 2000-2013 mpv/MPlayer/mplayer2 projects\n built on %s\n", mplayer_version, mplayer_builddate); } -static int print_version_opt(const m_option_t *opt, const char *name, - const char *param) -{ - print_version(true); - exit(0); -} - static bool handle_help_options(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; @@ -4641,14 +4633,13 @@ static int mpv_main(int argc, char *argv[]) struct MPOpts *opts = &mpctx->opts; // Create the config context and register the options mpctx->mconfig = m_config_new(opts, cfg_include); - m_config_register_options(mpctx->mconfig, mplayer_opts); - m_config_register_options(mpctx->mconfig, common_opts); + m_config_register_options(mpctx->mconfig, mp_opts); mp_input_register_options(mpctx->mconfig); // Preparse the command line m_config_preparse_command_line(mpctx->mconfig, argc, argv); - print_version(false); + mp_print_version(false); print_libav_versions(); if (!parse_cfgfiles(mpctx, mpctx->mconfig)) @@ -4674,8 +4665,8 @@ static int mpv_main(int argc, char *argv[]) mp_msg(MSGT_CPLAYER, MSGL_V, "\n"); if (!mpctx->playlist->first && !opts->player_idle_mode) { - print_version(true); - mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", mp_gtext(help_text)); + mp_print_version(true); + mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", mp_gtext(mp_help_text)); exit_player(mpctx, EXIT_NONE, 0); } diff --git a/core/options.c b/core/options.c index 5ee8770d2d..79d1370e7e 100644 --- a/core/options.c +++ b/core/options.c @@ -33,15 +33,17 @@ #include "stream/tv.h" #include "stream/stream_radio.h" #include "video/csputils.h" +#include "sub/sub.h" +#include "audio/mixer.h" +#include "audio/filter/af.h" +#include "audio/decode/dec_audio.h" +#include "mp_core.h" extern char *lirc_configfile; extern int mp_msg_color; extern int mp_msg_module; -/* defined in dec_video.c */ -extern int field_dominance; - /* from dec_audio, currently used for ac3surround decoder only */ extern int fakemono; @@ -55,11 +57,17 @@ extern const m_option_t cdda_opts[]; extern int sws_flags; extern const char pp_help[]; +extern const char mp_help_text[]; + static int print_version_opt(const m_option_t *opt, const char *name, - const char *param); + const char *param) +{ + mp_print_version(true); + exit(0); +} #ifdef CONFIG_RADIO -const m_option_t radioopts_conf[]={ +static const m_option_t radioopts_conf[]={ {"device", &stream_radio_defaults.device, CONF_TYPE_STRING, 0, 0 ,0, NULL}, {"driver", &stream_radio_defaults.driver, CONF_TYPE_STRING, 0, 0 ,0, NULL}, {"channels", &stream_radio_defaults.channels, CONF_TYPE_STRING_LIST, 0, 0 ,0, NULL}, @@ -72,7 +80,7 @@ const m_option_t radioopts_conf[]={ #endif /* CONFIG_RADIO */ #ifdef CONFIG_TV -const m_option_t tvopts_conf[]={ +static const m_option_t tvopts_conf[]={ {"immediatemode", &stream_tv_defaults.immediate, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL}, {"audio", &stream_tv_defaults.noaudio, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"audiorate", &stream_tv_defaults.audiorate, CONF_TYPE_INT, 0, 0, 0, NULL}, @@ -130,7 +138,7 @@ extern int pvr_param_bitrate_peak; extern char *pvr_param_stream_type; #ifdef CONFIG_PVR -const m_option_t pvropts_conf[]={ +static const m_option_t pvropts_conf[]={ {"aspect", &pvr_param_aspect_ratio, CONF_TYPE_INT, 0, 1, 4, NULL}, {"arate", &pvr_param_sample_rate, CONF_TYPE_INT, 0, 32000, 48000, NULL}, {"alayer", &pvr_param_audio_layer, CONF_TYPE_INT, 0, 1, 2, NULL}, @@ -154,7 +162,7 @@ extern float sws_lum_gblur; extern float sws_chr_sharpen; extern float sws_lum_sharpen; -const m_option_t scaler_filter_conf[]={ +static const m_option_t scaler_filter_conf[]={ {"lgb", &sws_lum_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL}, {"cgb", &sws_chr_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL}, {"cvs", &sws_chr_vshift, CONF_TYPE_INT, 0, 0, 0, NULL}, @@ -168,21 +176,18 @@ extern char *dvd_device, *cdrom_device; extern double mf_fps; extern char * mf_type; -extern m_obj_list_t vf_obj_list; +extern const m_obj_list_t vf_obj_list; -const m_option_t mfopts_conf[]={ +static const m_option_t mfopts_conf[]={ {"fps", &mf_fps, CONF_TYPE_DOUBLE, 0, 0, 0, NULL}, {"type", &mf_type, CONF_TYPE_STRING, 0, 0, 0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} }; -#include "audio/filter/af.h" -extern struct af_cfg af_cfg; // Audio filter configuration, defined in libmpcodecs/dec_audio.c - extern int mp_msg_levels[MSGT_MAX]; extern int mp_msg_level_all; -const m_option_t msgl_config[]={ +static const m_option_t msgl_config[]={ { "all", &mp_msg_level_all, CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL}, { "global", &mp_msg_levels[MSGT_GLOBAL], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL }, @@ -278,12 +283,29 @@ const m_option_t msgl_config[]={ }; -extern const m_option_t lavc_decode_opts_conf[]; -extern const m_option_t ad_lavc_decode_opts_conf[]; +#ifdef CONFIG_TV +static const m_option_t tvscan_conf[]={ + {"autostart", &stream_tv_defaults.scan, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"threshold", &stream_tv_defaults.scan_threshold, CONF_TYPE_INT, CONF_RANGE, 1, 100, NULL}, + {"period", &stream_tv_defaults.scan_period, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 2.0, NULL}, + {NULL, NULL, 0, 0, 0, 0, NULL} +}; +#endif #define OPT_BASE_STRUCT struct MPOpts -const m_option_t common_opts[] = { +extern const struct m_sub_options image_writer_conf; + +static const m_option_t screenshot_conf[] = { + OPT_SUBSTRUCT("", screenshot_image_opts, image_writer_conf, 0), + OPT_STRING("template", screenshot_template, 0), + {0}, +}; + +extern const m_option_t lavc_decode_opts_conf[]; +extern const m_option_t ad_lavc_decode_opts_conf[]; + +const m_option_t mp_opts[] = { // ------------------------- common options -------------------- OPT_FLAG("quiet", quiet, CONF_GLOBAL), {"really-quiet", &verbose, CONF_TYPE_STORE, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL}, @@ -434,7 +456,7 @@ const m_option_t common_opts[] = { {"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, - OPT_SETTINGSLIST("vf*", vf_settings, 0, &vf_obj_list), + OPT_SETTINGSLIST("vf*", vf_settings, 0, (void *) &vf_obj_list), OPT_STRING("ad", audio_decoders, 0), OPT_STRING("vd", video_decoders, 0), @@ -504,28 +526,6 @@ const m_option_t common_opts[] = { OPT_FLOATRANGE("osd-bar-h", osd_bar_h, 0, 0.1, 50), OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0), OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0), - {NULL, NULL, 0, 0, 0, 0, NULL} -}; - -#ifdef CONFIG_TV -const m_option_t tvscan_conf[]={ - {"autostart", &stream_tv_defaults.scan, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"threshold", &stream_tv_defaults.scan_threshold, CONF_TYPE_INT, CONF_RANGE, 1, 100, NULL}, - {"period", &stream_tv_defaults.scan_period, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 2.0, NULL}, - {NULL, NULL, 0, 0, 0, 0, NULL} -}; -#endif - -extern const struct m_sub_options image_writer_conf; - -const m_option_t screenshot_conf[] = { - OPT_SUBSTRUCT("", screenshot_image_opts, image_writer_conf, 0), - OPT_STRING("template", screenshot_template, 0), - {0}, -}; - -const m_option_t mplayer_opts[]={ - /* name, pointer, type, flags, min, max */ //---------------------- libao/libvo options ------------------------ OPT_STRINGLIST("vo", vo.video_driver_list, 0), @@ -699,8 +699,8 @@ const m_option_t mplayer_opts[]={ OPT_FLAG("list-properties", list_properties, CONF_GLOBAL), {"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL}, - {"help", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, - {"h", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, + {"help", (void *) mp_help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, + {"h", (void *) mp_help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, {"version", (void *)print_version_opt, CONF_TYPE_PRINT_FUNC, CONF_NOCFG|CONF_GLOBAL|M_OPT_PRE_PARSE}, {"V", (void *)print_version_opt, CONF_TYPE_PRINT_FUNC, CONF_NOCFG|CONF_GLOBAL|M_OPT_PRE_PARSE}, @@ -727,7 +727,7 @@ const m_option_t mplayer_opts[]={ {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const struct MPOpts mp_default_opts = { +const struct MPOpts mp_default_opts = { .reset_options = (char **)(const char *[]){"pause", NULL}, .audio_driver_list = NULL, .audio_decoders = "-spdif:*", // never select spdif by default diff --git a/core/options.h b/core/options.h index eaa908d7bd..42955cd730 100644 --- a/core/options.h +++ b/core/options.h @@ -268,4 +268,7 @@ typedef struct MPOpts { } encode_output; } MPOpts; +extern const m_option_t mp_opts[]; +extern const struct MPOpts mp_default_opts; + #endif -- cgit v1.2.3