Index: Makefile =================================================================== --- Makefile (revision 28306) +++ Makefile (working copy) @@ -433,6 +433,7 @@ stream/realrtsp/xbuffer.c \ SRCS_COMMON-$(PNG) += libmpcodecs/vd_mpng.c +SRCS_COMMON-$(PRIORITY) += osdep/$(PRIORITY_C) SRCS_COMMON-$(PVR) += stream/stream_pvr.c SRCS_COMMON-$(QTX_CODECS) += libmpcodecs/ad_qtaudio.c \ libmpcodecs/vd_qtvideo.c Index: configure =================================================================== --- configure (revision 28306) +++ configure (working copy) @@ -721,6 +725,8 @@ _def_stream_cache="#define CONFIG_STREAM_CACHE 1" _def_pthread_cache="#undef PTHREAD_CACHE" _need_shmem=yes +_def_priority="#undef CONFIG_PRIORITY" +_priority=no for ac_option do case "$ac_option" in --help|-help|-h) @@ -1432,6 +1442,9 @@ _ld_extra="$_ld_extra -lwinmm" _pe_executable=yes _timer=timer-win2.c + _def_priority="#define CONFIG_PRIORITY 1" + _priority=yes + _priority_c=priority-win.c fi if mingw32 ; then @@ -1454,6 +1467,9 @@ _exesuf=".exe" _getch=getch2-os2.c _need_shmem=no + _def_priority="#define CONFIG_PRIORITY 1" + _priority=yes + _priority_c=priority-os2.c fi for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do @@ -8049,6 +8115,8 @@ PE_EXECUTABLE = $_pe_executable PNG = $_png PNM = $_pnm +PRIORITY = $_priority +PRIORITY_C = $_priority_c PULSE = $_pulse PVR = $_pvr QTX_CODECS = $_qtx @@ -8307,6 +8375,7 @@ $_def_macosx_finder $_def_maemo $_def_named_asm_args +$_def_priority $_def_quicktime $_def_restrict_keyword $_def_rtc Index: DOCS/man/en/mplayer.1 =================================================================== --- DOCS/man/en/mplayer.1 (revision 28306) +++ DOCS/man/en/mplayer.1 (working copy) @@ -732,9 +732,9 @@ handle carriage return (i.e.\& \\r). . .TP -.B \-priority (Windows only) +.B \-priority (Windows and OS/2 only) Set process priority for MPlayer according to the predefined -priorities available under Windows. +priorities available under Windows and OS/2. Possible values of : .RSs idle|belownormal|normal|abovenormal|high|realtime Index: mplayer.c =================================================================== --- mplayer.c (revision 28306) +++ mplayer.c (working copy) @@ -88,8 +88,8 @@ int enable_mouse_movements=0; float start_volume = -1; -#if defined(__MINGW32__) || defined(__CYGWIN__) -char * proc_priority=NULL; +#ifdef CONFIG_PRIORITY +#include "osdep/priority.h" #endif char *heartbeat_cmd; @@ -689,8 +689,8 @@ if (mpctx->user_muted && !mpctx->edl_muted) mixer_mute(&mpctx->mixer); uninit_player(INITIALIZED_ALL); -#if defined(__MINGW32__) || defined(__CYGWIN__) - timeEndPeriod(1); +#ifdef CONFIG_PRIORITY + uninit_priority(1); #endif #ifdef CONFIG_X11 #ifdef CONFIG_GUI @@ -2632,20 +2636,10 @@ } #endif -#if defined(__MINGW32__) || defined(__CYGWIN__) - // request 1ms timer resolution - timeBeginPeriod(1); - 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,MSGTR_SettingProcessPriority, - priority_presets_defs[i].name); - SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio); - } +#ifdef CONFIG_PRIORITY + init_priority(1); #endif + #ifndef CONFIG_GUI if(use_gui){ mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui); Index: cfg-common.h =================================================================== --- cfg-common.h (revision 28306) +++ cfg-common.h (working copy) @@ -350,25 +350,6 @@ }; -#if defined(__MINGW32__) || defined(__CYGWIN__) -struct { - char* name; - int prio; -} priority_presets_defs[] = { - { "realtime", REALTIME_PRIORITY_CLASS}, - { "high", HIGH_PRIORITY_CLASS}, -#ifdef ABOVE_NORMAL_PRIORITY_CLASS - { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS}, -#endif - { "normal", NORMAL_PRIORITY_CLASS}, -#ifdef BELOW_NORMAL_PRIORITY_CLASS - { "belownormal", BELOW_NORMAL_PRIORITY_CLASS}, -#endif - { "idle", IDLE_PRIORITY_CLASS}, - { NULL, NORMAL_PRIORITY_CLASS} /* default */ -}; -#endif /* defined(__MINGW32__) || defined(__CYGWIN__) */ - extern const m_option_t noconfig_opts[]; extern const m_option_t lavc_decode_opts_conf[]; Index: cfg-common-opts.h =================================================================== --- cfg-common-opts.h (revision 28306) +++ cfg-common-opts.h (working copy) @@ -3,6 +3,10 @@ #include "config.h" +#ifdef CONFIG_PRIORITY +#include "osdep/priority.h" +#endif + // ------------------------- common options -------------------- {"quiet", &quiet, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"noquiet", &quiet, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, @@ -17,7 +21,7 @@ {"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL}, #endif {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, -#if defined(__MINGW32__) || defined(__CYGWIN__) +#ifdef CONFIG_PRIORITY {"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL}, #endif {"noconfig", noconfig_opts, CONF_TYPE_SUBCONFIG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL}, Index: mencoder.c =================================================================== --- mencoder.c (revision 28306) +++ mencoder.c (working copy) @@ -143,8 +143,8 @@ double cur_vout_time_usage=0; int benchmark=0; -#if defined(__MINGW32__) || defined(__CYGWIN__) -char * proc_priority=NULL; +#ifdef CONFIG_PRIORITY +#include "osdep/priority.h" #endif // A-V sync: @@ -516,17 +520,8 @@ } } -#if defined(__MINGW32__) || defined(__CYGWIN__) - 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,MSGTR_SettingProcessPriority, - priority_presets_defs[i].name); - SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio); - } +#ifdef CONFIG_PRIORITY + init_priority(0); #endif // check font Index: osdep/priority-win.c =================================================================== --- osdep/priority-win.c (revision 0) +++ osdep/priority-win.c (revision 0) @@ -0,0 +1,76 @@ +/* + * priority-win.c : implementation of '-priority' for Win32 + * + * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net) + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#define _UWIN 1 /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/ +#include + +#include + +#include "mp_msg.h" +#include "help_mp.h" + +#include "priority.h" + +char *proc_priority = NULL; + +static struct { + char* name; + int prio; +} priority_presets_defs[] = { + { "realtime", REALTIME_PRIORITY_CLASS}, + { "high", HIGH_PRIORITY_CLASS}, +#ifdef ABOVE_NORMAL_PRIORITY_CLASS + { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS}, +#endif + { "normal", NORMAL_PRIORITY_CLASS}, +#ifdef BELOW_NORMAL_PRIORITY_CLASS + { "belownormal", BELOW_NORMAL_PRIORITY_CLASS}, +#endif + { "idle", IDLE_PRIORITY_CLASS}, + { NULL, NORMAL_PRIORITY_CLASS} /* default */ +}; + +void init_priority(int init_timer_res) +{ + if(init_timer_res) + // request 1ms timer resolution + timeBeginPeriod(1); + + 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, MSGTR_SettingProcessPriority, + priority_presets_defs[i].name); + SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio); + } +} + +void uninit_priority(int uninit_timer_res) +{ + if(uninit_timer_res) + timeEndPeriod(1); +} Index: osdep/priority-os2.c =================================================================== --- osdep/priority-os2.c (revision 0) +++ osdep/priority-os2.c (revision 0) @@ -0,0 +1,71 @@ +/* + * priority-os2.c : implementation of '-priority' for OS/2 + * + * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net) + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#define INCL_DOS +#include + +#include + +#include "mp_msg.h" +#include "help_mp.h" + +#include "priority.h" + +char *proc_priority = NULL; + +static struct { + char* name; + int prio; +} priority_presets_defs[] = { + { "realtime", MAKESHORT(0, PRTYC_TIMECRITICAL)}, + { "high", MAKESHORT(PRTYD_MAXIMUM, PRTYC_REGULAR)}, + { "abovenormal", MAKESHORT(15, PRTYC_REGULAR)}, + { "normal", MAKESHORT(0, PRTYC_REGULAR)}, + { "belownormal", MAKESHORT(PRTYD_MAXIMUM, PRTYC_IDLETIME)}, + { "idle", MAKESHORT(0, PRTYC_IDLETIME)}, + { NULL, MAKESHORT(0, PRTYC_REGULAR)} /* default */ +}; + +void init_priority(int init_timer_res) +{ + 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, MSGTR_SettingProcessPriority, + priority_presets_defs[i].name); + + DosSetPriority(PRTYS_PROCESS, + HIBYTE(priority_presets_defs[i].prio), + LOBYTE(priority_presets_defs[i].prio), + 0); + } +} + +void uninit_priority(int uninit_timer_res) +{ +} + Index: osdep/priority.h =================================================================== --- osdep/priority.h (revision 0) +++ osdep/priority.h (revision 0) @@ -0,0 +1,33 @@ +/* + * priority.h : header for implementation of '-priority' + * + * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net) + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef MPLAYER_PRIORITY_H +#define MPLAYER_PRIORITY_H + +extern char *proc_priority; + +void init_priority(int init_timer_res); +void uninit_priority(int uninit_timer_res); + +#endif +