summaryrefslogtreecommitdiffstats
path: root/audio/lsmi/rtprio.diff
blob: 4322314f9ae19a0f22296e8394505df62f286151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
diff -Naur lsmi/lsmi-joystick.c lsmi.patched//lsmi-joystick.c
--- lsmi/lsmi-joystick.c	2012-05-14 20:08:19.000000000 -0400
+++ lsmi.patched//lsmi-joystick.c	2012-05-14 20:15:16.000000000 -0400
@@ -46,6 +46,7 @@
 #include <sys/time.h>
 #include <signal.h>
 #include <getopt.h>
+#include <sched.h>
 
 #include "seq.h"
 #include "sig.h"
@@ -99,6 +100,7 @@
 	"Options:\n\n"
 		" -h | --help                   Show this message\n"
 		" -d | --device specialfile     Event device to use (instead of js0)\n"
+		" -R | --realtime rtprio        Use realtime priority 'rtprio' (requires privs)\n"
 		" -v | --verbose                Be verbose (show note events)\n"
 		" -p | --port client:port       Connect to ALSA Sequencer client on startup\n"					
 		" -n | --no-hold                Send controller data even when no joystick button is held\n" );
@@ -121,6 +123,7 @@
 		{ "verbose", no_argument, NULL, 'v' },
 		{ "device", required_argument, NULL, 'd' },
 		{ "no-hold", no_argument, NULL, 'n' },
+		{ "realtime", required_argument, NULL, 'R' },
 		{ "daemon", no_argument, NULL, 'z' },
 		{ NULL, 0, NULL, 0 }
 	};
@@ -164,6 +167,23 @@
 			case 'z':
 				daemonize = 1;
 				break;
+			case 'R':
+				{
+					struct sched_param sp;
+
+					sp.sched_priority = atoi( optarg );
+
+					if ( sched_setscheduler( 0, SCHED_FIFO, &sp ) < 0 )
+					{
+						perror( "sched_setscheduler()" );
+						fprintf( stderr, "Failed to get realtime priority!\n" );
+						exit( 1 );
+					}
+
+					fprintf( stderr, "Using realtime priority %i.\n", 
+						sp.sched_priority );
+				}
+				break;
 		}
 
 	}
diff -Naur lsmi/lsmi-keyhack.c lsmi.patched//lsmi-keyhack.c
--- lsmi/lsmi-keyhack.c	2012-05-14 20:08:19.000000000 -0400
+++ lsmi.patched//lsmi-keyhack.c	2012-05-14 20:14:07.000000000 -0400
@@ -111,6 +111,7 @@
 #include <getopt.h>
 
 #include <linux/input.h>
+#include <sched.h>
 #include <stdint.h>
 
 #include "seq.h"
@@ -261,6 +262,7 @@
 		" -h | --help                   Show this message\n"
 		" -d | --device specialfile     Event device to use (instead of event0)\n"
 		" -v | --verbose                Be verbose (show note events)\n"
+		" -R | --realtime rtprio        Use realtime priority 'rtprio' (requires privs)\n"
 		" -c | --channel n              Initial MIDI channel\n"
 		" -p | --port client:port       Connect to ALSA Sequencer client on startup\n"					
 		" -k | --keydata file			Name file to read/write key mappings (instead of ~/.keydb)\n"
@@ -281,6 +283,7 @@
 		{ "channel", required_argument, NULL, 'c' },
 		{ "device", required_argument, NULL, 'd' },
 		{ "keydata", required_argument, NULL, 'k' },
+		{ "realtime", required_argument, NULL, 'R' },
 		{ "verbose", no_argument, NULL, 'v' },
 		{ NULL, 0, NULL, 0 }
 	};
@@ -320,6 +323,23 @@
 			case 'v':
 				verbose = 1;
 				break;
+			case 'R':
+				{
+					struct sched_param sp;
+
+					sp.sched_priority = atoi( optarg );
+
+					if ( sched_setscheduler( 0, SCHED_FIFO, &sp ) < 0 )
+					{
+						perror( "sched_setscheduler()" );
+						fprintf( stderr, "Failed to get realtime priority!\n" );
+						exit( 1 );
+					}
+
+					fprintf( stderr, "Using realtime priority %i.\n", 
+						sp.sched_priority );
+				}
+				break;
 		}
 
 	}
diff -Naur lsmi/lsmi-mouse.c lsmi.patched//lsmi-mouse.c
--- lsmi/lsmi-mouse.c	2012-05-14 20:08:19.000000000 -0400
+++ lsmi.patched//lsmi-mouse.c	2012-05-14 20:11:08.000000000 -0400
@@ -55,6 +55,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 
+#include <sched.h>
 #include <stdint.h>
 
 #include <getopt.h>
@@ -144,6 +145,7 @@
 		" -h | --help                   Show this message\n"
 		" -d | --device specialfile     Event device to use (instead of event0)\n"
 		" -v | --verbose                Be verbose (show note events)\n"
+		" -R | --realtime rtprio        Use realtime priority 'rtprio' (requires privs)\n"
 		" -p | --port client:port       Connect to ALSA Sequencer client on startup\n"					
 
 		" -1 | --button-one 'c'|'n':n:n     Button mapping\n"
@@ -169,6 +171,7 @@
 		{ "button-one", required_argument, NULL, '1' },
 		{ "button-two", required_argument, NULL, '2' },
 		{ "button-three", required_argument, NULL, '3' },
+		{ "realtime", required_argument, NULL, 'R' },
 		{ "daemon", no_argument, NULL, 'z' },
 		{ NULL, 0, NULL, 0 }
 	};
@@ -202,6 +205,23 @@
 			case '3':
 				parse_map( 2, optarg );
 				break;
+			case 'R':
+				{
+					struct sched_param sp;
+
+					sp.sched_priority = atoi( optarg );
+
+					if ( sched_setscheduler( 0, SCHED_FIFO, &sp ) < 0 )
+					{
+						perror( "sched_setscheduler()" );
+						fprintf( stderr, "Failed to get realtime priority!\n" );
+						exit( 1 );
+					}
+
+					fprintf( stderr, "Using realtime priority %i.\n", 
+						sp.sched_priority );
+				}
+				break;
 			case 'z':
 				daemonize = 1;
 				break;