[MPlayer-cygwin] [patch] Simple priority support for win32 NOVIRUS

NoiseEHC NoiseEHC at freemail.hu
Fri Apr 1 14:05:16 CEST 2005


realtime priority will preemt all system threads, so only interrups will 
work.
it is easy to lock up az NT system:

SetProcessPriority(...REALTIME_PRIORITY_CLASS...);
while(true);

So if somehow the player encounters a tight loop you will get a freezed 
system...

Rune Petersen wrote:

> Diego Biurrun wrote:
>
>>> Here is a patch with mencoder changes, just in case you agree on this.
>>
>>
>>
>> I don't agree with leaving out realtime priority, as stated above
>> numerous times ;-p
>
>
> Ok, realtime goes back in =)
>
>
> Rune Petersen
>
>
> __________ NOD32 1.1042 (20050331) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.nod32.com
>
>------------------------------------------------------------------------
>
>diff -Naur a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
>--- a/DOCS/man/en/mplayer.1	2005-03-21 02:12:44.000000000 +0100
>+++ b/DOCS/man/en/mplayer.1	2005-04-01 10:14:20.000000000 +0200
>@@ -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
>diff -Naur a/cfg-common.h b/cfg-common.h
>--- a/cfg-common.h	2005-03-19 21:55:52.000000000 +0100
>+++ b/cfg-common.h	2005-04-01 10:50:10.375000000 +0200
>@@ -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
>diff -Naur a/mencoder.c b/mencoder.c
>--- a/mencoder.c	2005-03-24 00:29:54.000000000 +0100
>+++ b/mencoder.c	2005-04-01 01:56:52.203125000 +0200
>@@ -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
>diff -Naur a/mplayer.c b/mplayer.c
>--- a/mplayer.c	2005-02-25 12:11:08.000000000 +0100
>+++ b/mplayer.c	2005-04-01 02:05:42.046875000 +0200
>@@ -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);
>
>
>__________ NOD32 1.1042 (20050331) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.nod32.com
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>MPlayer-cygwin mailing list
>MPlayer-cygwin at mplayerhq.hu
>http://mplayerhq.hu/mailman/listinfo/mplayer-cygwin
>
>
>__________ NOD32 1.1042 (20050331) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.nod32.com
>
>  
>




More information about the MPlayer-cygwin mailing list