From 7eb48343d47981fc38e0d4c7d9c78ae7ac2662b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sat, 13 Nov 2010 22:10:58 +0100 Subject: options: more mplayer.c options moved to option struct Following options were moved: autoq, benchmark, [no]term-osd, term-osd-esc, playing-msg, [no]idle, [no]consolecontrols, list-properties. --- cfg-mplayer.h | 19 ++++++++----------- command.c | 2 +- defaultopts.c | 3 +++ mp_osd.h | 3 --- mplayer.c | 58 ++++++++++++++++++++++++++-------------------------------- options.h | 8 ++++++++ 6 files changed, 46 insertions(+), 47 deletions(-) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index d00aa379f4..0584957215 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -273,9 +273,9 @@ const m_option_t mplayer_opts[]={ {"hardframedrop", &frame_dropping, CONF_TYPE_FLAG, 0, 0, 2, NULL}, {"noframedrop", &frame_dropping, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"autoq", &auto_quality, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, + OPT_INTRANGE("autoq", auto_quality, 0, 0, 100), - {"benchmark", &benchmark, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + OPT_FLAG_ON("benchmark", benchmark, 0), // dump some stream out instead of playing the file // this really should be in MEncoder instead of MPlayer... -> TODO @@ -319,18 +319,15 @@ const m_option_t mplayer_opts[]={ OPT_STRING("rtc-device", rtc_device, 0), #endif - {"term-osd", &term_osd, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"noterm-osd", &term_osd, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"term-osd-esc", &term_osd_esc, CONF_TYPE_STRING, 0, 0, 1, NULL}, - {"playing-msg", &playing_msg, CONF_TYPE_STRING, 0, 0, 0, NULL}, + OPT_MAKE_FLAGS("term-osd", term_osd, 0), + OPT_STRING("term-osd-esc", term_osd_esc, 0), + OPT_STRING("playing-msg", playing_msg, 0), {"slave", &slave_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL}, - {"idle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL}, - {"noidle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 1, 0, NULL}, + OPT_MAKE_FLAGS("idle", player_idle_mode, CONF_GLOBAL), {"use-stdin", "-use-stdin has been renamed to -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL}, OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000), - {"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, - {"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, + OPT_MAKE_FLAGS("consolecontrols", consolecontrols, CONF_GLOBAL), {"mouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"nomouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000), @@ -340,7 +337,7 @@ const m_option_t mplayer_opts[]={ {"tvscan", "MPlayer was compiled without TV interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif /* CONFIG_TV */ - {"list-properties", &list_properties, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, + OPT_FLAG_ON("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}, {"help", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, diff --git a/command.c b/command.c index f099322428..4ffe29a351 100644 --- a/command.c +++ b/command.c @@ -2924,7 +2924,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_OSD:{ int v = cmd->args[0].v.i; - int max = (term_osd + int max = (opts->term_osd && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL; if (opts->osd_level > max) opts->osd_level = max; diff --git a/defaultopts.c b/defaultopts.c index 5b4e8f762f..e8f842cd47 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -29,7 +29,10 @@ void set_default_mplayer_options(struct MPOpts *opts) .edition_id = -1, .user_correct_pts = -1, .initial_audio_sync = 1, + .term_osd = 1, + .term_osd_esc = "\x1b[A\r\x1b[K", .key_fifo_size = 7, + .consolecontrols = 1, .doubleclick_time = 300, .audio_id = -1, .video_id = -1, diff --git a/mp_osd.h b/mp_osd.h index 7c5da6b7a9..6c80ea3214 100644 --- a/mp_osd.h +++ b/mp_osd.h @@ -34,9 +34,6 @@ #define MAX_OSD_LEVEL 3 #define MAX_TERM_OSD_LEVEL 1 -// These appear in options list -extern int term_osd; - struct MPContext; void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val); diff --git a/mplayer.c b/mplayer.c index 840b0950f2..7adde18740 100644 --- a/mplayer.c +++ b/mplayer.c @@ -100,7 +100,6 @@ const int under_mencoder = 0; int slave_mode=0; -int player_idle_mode=0; int enable_mouse_movements=0; float start_volume = -1; @@ -265,10 +264,7 @@ static const char help_text[]=_( //**************************************************************************// //**************************************************************************// -// Common FIFO functions, and keyboard/event FIFO code #include "mp_fifo.h" -int noconsolecontrols=0; -//**************************************************************************// // benchmark: double video_time_usage=0; @@ -277,17 +273,10 @@ static double audio_time_usage=0; static int total_time_usage_start=0; static int total_frame_cnt=0; static int drop_frame_cnt=0; // total number of dropped frames -int benchmark=0; // options: - int auto_quality=0; static int output_quality=0; -static int list_properties = 0; - -int term_osd = 1; -static char* term_osd_esc = "\x1b[A\r\x1b[K"; -static char* playing_msg = NULL; // seek: static double seek_to_sec; static off_t seek_to_byte=0; @@ -1666,7 +1655,9 @@ static void update_osd_msg(struct MPContext *mpctx) if (strcmp(osd->osd_text, msg->msg)) { strncpy(osd->osd_text, msg->msg, 127); if(mpctx->sh_video) vo_osd_changed(OSDTYPE_OSD); else - if(term_osd) mp_msg(MSGT_CPLAYER,MSGL_STATUS,"%s%s\n",term_osd_esc,msg->msg); + if(opts->term_osd) + mp_msg(MSGT_CPLAYER,MSGL_STATUS, "%s%s\n", opts->term_osd_esc, + msg->msg); } return; } @@ -1707,9 +1698,9 @@ static void update_osd_msg(struct MPContext *mpctx) } // Clear the term osd line - if (term_osd && osd->osd_text[0]) { + if (opts->term_osd && osd->osd_text[0]) { osd->osd_text[0] = 0; - printf("%s\n",term_osd_esc); + printf("%s\n", opts->term_osd_esc); } } @@ -2331,7 +2322,7 @@ static int sleep_until_update(struct MPContext *mpctx, float *time_frame, // don't try to "catch up". // If benchmark is set always output frames as fast as possible // without sleeping. - if (*time_frame < -0.2 || benchmark) + if (*time_frame < -0.2 || opts->benchmark) *time_frame = 0; *time_frame -= mpctx->video_out->flip_queue_offset; } @@ -2442,11 +2433,13 @@ int reinit_video_chain(struct MPContext *mpctx) sh_video->num_buffered_pts = 0; sh_video->next_frame_time = 0; - if(auto_quality>0){ + if (opts->auto_quality > 0) { // Auto quality option enabled output_quality=get_video_quality_max(sh_video); - if(auto_quality>output_quality) auto_quality=output_quality; - else output_quality=auto_quality; + if (opts->auto_quality > output_quality) + opts->auto_quality = output_quality; + else + output_quality = opts->auto_quality; mp_msg(MSGT_CPLAYER,MSGL_V,"AutoQ: setting quality to %d.\n",output_quality); set_video_quality(sh_video,output_quality); } @@ -2679,7 +2672,7 @@ static void pause_loop(struct MPContext *mpctx) // Small hack to display the pause message on the OSD line. // The pause string is: "\n == PAUSE == \r" so we need to // take the first and the last char out - if (term_osd && !mpctx->sh_video) { + if (opts->term_osd && !mpctx->sh_video) { char msg[128] = _("\n ===== PAUSE =====\r"); int mlen = strlen(msg); msg[mlen-1] = '\0'; @@ -3395,7 +3388,7 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){ mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); opt_exit = 1; } - if(list_properties) { + if (opts->list_properties) { property_print_help(); opt_exit = 1; } @@ -3403,7 +3396,7 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){ if(opt_exit) exit_player(mpctx, EXIT_NONE); - if(!mpctx->filename && !player_idle_mode){ + if (!mpctx->filename && !opts->player_idle_mode) { // no file/vcd/dvd -> show HELP: mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", mp_gtext(help_text)); exit_player_with_rc(mpctx, EXIT_NONE, 0); @@ -3498,7 +3491,7 @@ current_module = "init_input"; mp_input_add_key_fd(mpctx->input, -1,0,mplayer_get_key,NULL, mpctx->key_fifo); if(slave_mode) mp_input_add_cmd_fd(mpctx->input, 0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL); -else if(!noconsolecontrols) +else if (opts->consolecontrols) mp_input_add_key_fd(mpctx->input, 0, 1, read_keys, NULL, mpctx->key_fifo); // Set the libstream interrupt callback stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input); @@ -3577,7 +3570,7 @@ play_next_file: // We must enable getch2 here to be able to interrupt network connection // or cache filling -if(!noconsolecontrols && !slave_mode){ +if (opts->consolecontrols && !slave_mode) { if(mpctx->initialized_flags&INITIALIZED_GETCH2) mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"WARNING: getch2_init called twice!\n"); else @@ -3587,7 +3580,7 @@ if(!noconsolecontrols && !slave_mode){ } // =================== GUI idle loop (STOP state) =========================== -while (player_idle_mode && !mpctx->filename) { +while (opts->player_idle_mode && !mpctx->filename) { play_tree_t * entry = NULL; mp_cmd_t * cmd; if (mpctx->video_out && mpctx->video_out->config_ok) @@ -4106,15 +4099,16 @@ if(!reinit_video_chain(mpctx)) { main: current_module="main"; - if(playing_msg) { - char* msg = property_expand_string(mpctx, playing_msg); + if (opts->playing_msg) { + char* msg = property_expand_string(mpctx, opts->playing_msg); mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s",msg); free(msg); } // Disable the term OSD in verbose mode -if(verbose) term_osd = 0; +if (verbose) + opts->term_osd = 0; { int frame_time_remaining=0; // flag @@ -4388,11 +4382,11 @@ if(!mpctx->sh_video) { //============================ Auto QUALITY ============================ /*Output quality adjustments:*/ -if(auto_quality>0){ +if (opts->auto_quality > 0) { current_module="autoq"; // float total=0.000001f * (GetTimer()-aq_total_time); -// if(output_quality0.05f*total) - if(output_quality0) +// if (output_quality < opts->auto_quality && aq_sleep_time > 0.05f * total) + if (output_quality < opts->auto_quality && aq_sleep_time > 0) ++output_quality; else // if(output_quality>0 && aq_sleep_time<-0.05f*total) @@ -4536,7 +4530,7 @@ goto_next_file: // don't jump here after ao/vo/getch initialization! mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n"); -if(benchmark){ +if (opts->benchmark) { double tot=video_time_usage+vout_time_usage+audio_time_usage; double total_time_usage; total_time_usage_start=GetTimer()-total_time_usage_start; @@ -4625,7 +4619,7 @@ while(mpctx->playtree_iter != NULL) { break; } -if(mpctx->playtree_iter != NULL || player_idle_mode){ +if (mpctx->playtree_iter != NULL || opts->player_idle_mode) { if(!mpctx->playtree_iter) mpctx->filename = NULL; mpctx->stop_play = 0; goto play_next_file; diff --git a/options.h b/options.h index 7517f3a172..992202fda3 100644 --- a/options.h +++ b/options.h @@ -31,6 +31,8 @@ typedef struct MPOpts { int osd_level; int osd_duration; + int auto_quality; + int benchmark; char *stream_dump_name; int capture_dump; int loop_times; @@ -48,8 +50,14 @@ typedef struct MPOpts { int softsleep; int rtc; char *rtc_device; + int term_osd; + char *term_osd_esc; + char *playing_msg; + int player_idle_mode; int key_fifo_size; + int consolecontrols; int doubleclick_time; + int list_properties; int audio_id; int video_id; int sub_id; -- cgit v1.2.3