changeset 15042:265d8b8adbbe

windows priority support patch by Rune Petersen <runner at mail.tele.dk> with the freedom to shoot yourself in the foot
author faust3
date Sat, 02 Apr 2005 18:29:16 +0000
parents be6bf99741c6
children e2b2c72aa971
files DOCS/man/en/mplayer.1 cfg-common.h mencoder.c mplayer.c
diffstat 4 files changed, 65 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sat Apr 02 16:38:14 2005 +0000
+++ b/DOCS/man/en/mplayer.1	Sat Apr 02 18:29:16 2005 +0000
@@ -433,6 +433,19 @@
 handle carriage return (i.e.\& \\r).
 .
 .TP
+.B \-priority <prio> (Windows only)
+Set process priority for MPlayer according to Windows predefined priorities.
+.sp 1
+Possible values of <prio>:
+.RSs
+idle|belownormal|normal|abovenormal|high|realtime
+.sp 1
+.I Warning:
+.br
+Using realtime priority can cause system lockup.
+.RE
+.
+.TP
 .B \-v, \-verbose
 Increment verbose level (more \-v means more verbosity).
 .PD 0
--- a/cfg-common.h	Sat Apr 02 16:38:14 2005 +0000
+++ b/cfg-common.h	Sat Apr 02 18:29:16 2005 +0000
@@ -6,6 +6,7 @@
 	{"verbose", &verbose, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 0, 100, NULL},
 	{"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL},
+	{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
 
 // ------------------------- stream options --------------------
 
@@ -470,6 +471,24 @@
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+#ifdef WIN32
+
+extern char * proc_priority;
+
+struct {
+  char* name;
+  int prio;
+} priority_presets_defs[] = {
+  { "realtime", REALTIME_PRIORITY_CLASS},
+  { "high", HIGH_PRIORITY_CLASS},
+  { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS},
+  { "normal", NORMAL_PRIORITY_CLASS},
+  { "belownormal", BELOW_NORMAL_PRIORITY_CLASS},
+  { "idle", IDLE_PRIORITY_CLASS},
+  { NULL, NORMAL_PRIORITY_CLASS} /* default */
+};
+#endif /* WIN32 */
+
 #ifdef USE_LIBAVCODEC
 extern m_option_t lavc_decode_opts_conf[];
 #endif
--- a/mencoder.c	Sat Apr 02 16:38:14 2005 +0000
+++ b/mencoder.c	Sat Apr 02 18:29:16 2005 +0000
@@ -153,6 +153,10 @@
 double cur_vout_time_usage=0;
 int benchmark=0;
 
+#ifdef WIN32
+char * proc_priority=NULL;
+#endif
+
 // A-V sync:
 int delay_corrected=1;
 static float default_max_pts_correction=-1;//0.01f;
@@ -479,6 +483,19 @@
 
   mp_msg_set_level(verbose+MSGL_STATUS);
 
+#ifdef WIN32
+  if(proc_priority){
+    int i;
+    for(i=0; priority_presets_defs[i].name; i++){
+      if(strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)
+        break;
+    }
+    mp_msg(MSGT_CPLAYER,MSGL_STATUS,"Setting process priority: %s\n",
+					priority_presets_defs[i].name);
+    SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);
+  }
+#endif	
+
 // check font
 #ifdef USE_OSD
 #ifdef HAVE_FREETYPE
--- a/mplayer.c	Sat Apr 02 16:38:14 2005 +0000
+++ b/mplayer.c	Sat Apr 02 18:29:16 2005 +0000
@@ -88,6 +88,10 @@
 int identify=0;
 int quiet=0;
 
+#ifdef WIN32
+char * proc_priority=NULL;
+#endif
+
 #define ABS(x) (((x)>=0)?(x):(-(x)))
 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
 
@@ -1145,6 +1149,18 @@
       }
     }
 	
+#ifdef WIN32
+	if(proc_priority){
+		int i;
+        	for(i=0; priority_presets_defs[i].name; i++){
+        		if(strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)
+				break;
+		}
+		mp_msg(MSGT_CPLAYER,MSGL_STATUS,"Setting process priority: %s\n",
+				priority_presets_defs[i].name);
+		SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);
+	}
+#endif	
 #ifndef HAVE_NEW_GUI
     if(use_gui){
       mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui);