[MPlayer-cygwin] Change priority to realtime in windows

Joseph Miller joseph at tidetamerboatlifts.com
Tue Oct 5 20:13:38 CEST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here is the code in the attached file. I neglected to make a patch thus far as 
I'm not very good at that, but I will try to make one and send it out in the 
next few days.

- -Joseph

On Tuesday 05 October 2004 12:20 pm, Joey Parrish wrote:
> On Tue, Oct 05, 2004 at 01:02:54PM +0200, Diego Biurrun wrote:
> > Joseph Miller writes:
> > > On Sunday 26 September 2004 6:28 pm, Daniel Johansson wrote:
> > > > Hi, how to I change so that mplayer gets realtime priority by windows
> > > > every time I start a movie? I got some problems with laggy movies but
> > > > it works fine as soon as I change the priority to realtime. Is there
> > > > any way to tell mplayer to always use realtime as priority, if so
> > > > how?
> > >
> > > SetThreadPriority in winbase.h ought to help you out some.
> > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllpro
> > >c/base/setthreadpriority.asp
> >
> > Any volunteers to implement something like this as an option?  It has
> > been requested many many times..
>
> #ifdef WIN32
> # include <windows.h>
> #endif
>   [...]
> #ifdef WIN32
>   SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_TIME_CRITICAL);
> #endif
>
> IMHO, "time critical" is helpful, but not so aggressive that it even
> needs to be optional.  I do this in my packages.  With this priority,
> MPlayer gets preference over other normal apps, but will still defer CPU
> time to critical OS tasks.
>
> However, I think "real time" priority is bad, because it means as soon
> as I try to play an extremely high bitrate file that my CPU just can't
> handle, MPlayer eats up 100% CPU and gets priority over a lot of basic
> windows components.  I think this is a bad idea always.
>
> --Joey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD4DBQFBYuRVmXZROF+EADURAh0EAJsFIcVl3pYAjkxeCGB8ZiMsnGWsCgCYiBRx
5ki7QE65/srALOG4D/v5GQ==
=Ij8C
-----END PGP SIGNATURE-----
-------------- next part --------------
// in mplayer.c and mencoder.c (global declarations)
#ifdef WIN32
int win32priority=0;
#endif

// in cfg-common.h
#ifdef WIN32
	{"win32priority", &win32priority, CONF_TYPE_INT, CONF_RANGE, 1, 7, NULL},
#endif


// In main() of mplayer.c and mencoder.c (or put in separate function)
#ifdef WIN32
switch (win32priority) {
	case 0:
		// do nothing
	break;

	case 1:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_LOWEST);
	break;

	case 2:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_BELOW_NORMAL);
	break;

	case 3:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_NORMAL);
	break;

	case 4:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_IDLE);
	break;

	case 5:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_ABOVE_NORMAL);
	break;

	case 6:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_HIGHEST);
	break;

	case 7:
		SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_TIME_CRITICAL);
	break;

	default:
	break;
}
#endif


More information about the MPlayer-cygwin mailing list