Merge svn changes up to r28862
[mplayer.git] / osdep / priority.c
blob7a75153fa04e5a5593ee647b00f5241f0273d9aa
1 /*
2 * implementation of '-priority' for OS/2 and Win32
4 * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net)
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifdef __OS2__
25 #define INCL_DOS
26 #include <os2.h>
28 #define REALTIME_PRIORITY_CLASS MAKESHORT(0, PRTYC_TIMECRITICAL)
29 #define HIGH_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_REGULAR)
30 #define ABOVE_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM / 2, PRTYC_REGULAR)
31 #define NORMAL_PRIORITY_CLASS MAKESHORT(0, PRTYC_REGULAR)
32 #define BELOW_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_IDLETIME)
33 #define IDLE_PRIORITY_CLASS MAKESHORT(0, PRTYC_IDLETIME)
35 #else
37 #include <windows.h>
39 #endif /* __OS2__ */
41 #include <string.h>
43 #include "mp_msg.h"
44 #include "help_mp.h"
46 #include "priority.h"
48 char *proc_priority = NULL;
50 void set_priority(void)
52 struct {
53 char* name;
54 int prio;
55 } priority_presets_defs[] = {
56 { "realtime", REALTIME_PRIORITY_CLASS},
57 { "high", HIGH_PRIORITY_CLASS},
58 #ifdef ABOVE_NORMAL_PRIORITY_CLASS
59 { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS},
60 #endif
61 { "normal", NORMAL_PRIORITY_CLASS},
62 #ifdef BELOW_NORMAL_PRIORITY_CLASS
63 { "belownormal", BELOW_NORMAL_PRIORITY_CLASS},
64 #endif
65 { "idle", IDLE_PRIORITY_CLASS},
66 { NULL, NORMAL_PRIORITY_CLASS} /* default */
69 if (proc_priority) {
70 int i;
72 for (i = 0; priority_presets_defs[i].name; i++) {
73 if (strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)
74 break;
76 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_SettingProcessPriority,
77 priority_presets_defs[i].name);
79 #ifdef __OS2__
80 DosSetPriority(PRTYS_PROCESS,
81 HIBYTE(priority_presets_defs[i].prio),
82 LOBYTE(priority_presets_defs[i].prio),
83 0);
84 #else
85 SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);
86 #endif