comparison osdep/priority.c @ 28485:3f597aacbb69

Add priority support for OS/2 and factorize the Windows priority support. patch by KO Myung-Hun, komh chollian net
author diego
date Tue, 10 Feb 2009 15:34:44 +0000
parents
children 01b2dcc76143
comparison
equal deleted inserted replaced
28484:6abda55d2574 28485:3f597aacbb69
1 /*
2 * implementation of '-priority' for OS/2 and Win32
3 *
4 * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net)
5 *
6 * This file is part of MPlayer.
7 *
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.
12 *
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.
17 *
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.
21 */
22
23 #ifdef __OS2__
24
25 #define INCL_DOS
26 #include <os2.h>
27
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)
34
35 #else
36
37 /* Disable non-underscored versions of non-ANSI functions
38 * as otherwise int eof would conflict with eof(). */
39 #define _UWIN 1
40 #include <windows.h>
41
42 #endif /* __OS2__ */
43
44 #include <string.h>
45
46 #include "mp_msg.h"
47 #include "help_mp.h"
48
49 #include "priority.h"
50
51 char *proc_priority = NULL;
52
53 void set_priority(void)
54 {
55 struct {
56 char* name;
57 int prio;
58 } priority_presets_defs[] = {
59 { "realtime", REALTIME_PRIORITY_CLASS},
60 { "high", HIGH_PRIORITY_CLASS},
61 #ifdef ABOVE_NORMAL_PRIORITY_CLASS
62 { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS},
63 #endif
64 { "normal", NORMAL_PRIORITY_CLASS},
65 #ifdef BELOW_NORMAL_PRIORITY_CLASS
66 { "belownormal", BELOW_NORMAL_PRIORITY_CLASS},
67 #endif
68 { "idle", IDLE_PRIORITY_CLASS},
69 { NULL, NORMAL_PRIORITY_CLASS} /* default */
70 };
71
72 if (proc_priority) {
73 int i;
74
75 for (i = 0; priority_presets_defs[i].name; i++) {
76 if (strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)
77 break;
78 }
79 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_SettingProcessPriority,
80 priority_presets_defs[i].name);
81
82 #ifdef __OS2__
83 DosSetPriority(PRTYS_PROCESS,
84 HIBYTE(priority_presets_defs[i].prio),
85 LOBYTE(priority_presets_defs[i].prio),
86 0);
87 #else
88 SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);
89 #endif
90 }
91 }
92