Lines 10-17
Link Here
|
10 |
|
10 |
|
11 |
: ${jackd_enable="NO"} |
11 |
: ${jackd_enable="NO"} |
12 |
: ${jackd_user="root"} |
12 |
: ${jackd_user="root"} |
13 |
: ${jackd_rtprio="NO"} |
13 |
: ${jackd_rtprio="YES"} |
14 |
: ${jackd_args="-r -doss -r44100 -p1024 -n3 -w16"} |
14 |
: ${jackd_args="-r -doss -r48000 -p1024 -w16"} |
15 |
|
15 |
|
16 |
. /etc/rc.subr |
16 |
. /etc/rc.subr |
17 |
|
17 |
|
Lines 20-34
rcvar=jackd_enable
Link Here
|
20 |
procname=%%PREFIX%%/bin/jackd |
20 |
procname=%%PREFIX%%/bin/jackd |
21 |
start_cmd="start_jackd" |
21 |
start_cmd="start_jackd" |
22 |
|
22 |
|
|
|
23 |
fail() { |
24 |
echo "JACK failed to start: $1" >&2 |
25 |
exit 1 |
26 |
} |
27 |
|
23 |
start_jackd() { |
28 |
start_jackd() { |
24 |
echo "Starting ${name}." |
29 |
echo "Starting ${name}." |
25 |
if [ $jackd_rtprio = "YES" ]; then |
30 |
|
26 |
local rt="rtprio 1" |
31 |
# check that jackd_user is set |
|
|
32 |
if [ -z "$jackd_user" ]; then |
33 |
fail "jackd_user has to be defined" |
34 |
fi |
35 |
|
36 |
# check that jackd_args doesn't contain -R, or -r because we explicitly set them below |
37 |
if echo $jackd_args | grep -qw -- "-R"; then |
38 |
fail "jackd_args contains -R which isn't allowed: it is set automatically only when needed" |
39 |
fi |
40 |
if echo $jackd_args | grep -qw -- "-r"; then |
41 |
fail "jackd_args contains -r which isn't allowed: it is set automatically only when needed" |
42 |
fi |
43 |
|
44 |
# enable real-time priority if requested |
45 |
if [ "$jackd_rtprio" = "YES" ]; then |
46 |
# check that mac_priority(4) is enabled |
47 |
if [ "$(sysctl -qn security.mac.priority.realtime)" != "1" ]; then |
48 |
fail "jackd_rtprio=\"YES\" but mac_priority(4) isn't enabled on this system" |
49 |
fi |
50 |
# check that the group 'realtime' exists |
51 |
if ! getent group realtime > /dev/null; then |
52 |
fail "jackd_rtprio=\"YES\" but the group 'realtime' doesn't exist" |
53 |
fi |
54 |
# check that the user is in the realtime group |
55 |
if ! (getent group realtime | grep -qw "$jackd_user"); then |
56 |
fail "jackd_rtprio=\"YES\" but the user jackd_user=$jackd_user isn't in the realtime group" |
57 |
fi |
58 |
|
59 |
# enable the real-time priority functionality in JACK |
60 |
jackd_args="-R $jackd_args" |
61 |
else |
62 |
echo "Warning: The real-time priority feature is disabled by jackd_rtprio=${jackd_rtprio}." |
63 |
echo " For real-time priority:" |
64 |
echo " (1) enable mac_priority(4) on the system by adding mac_priority_load=\"YES\" to loader.conf" |
65 |
echo " (2) add the user jackd_user=$jackd_user to the group 'realtime'" |
66 |
echo " (3) set jackd_rtprio=\"YES\"" |
67 |
|
68 |
# enable the non-real-time priority functionality in JACK |
69 |
jackd_args="-r $jackd_args" |
27 |
fi |
70 |
fi |
28 |
# log the date and parameters |
71 |
# log the date and parameters |
29 |
echo -e "\n[`date`] Starting the daemon, user=$jackd_user rtprio=$jackd_rtprio args=\"$jackd_args\"" >> /var/log/${name}.log |
72 |
echo -e "\n[`date`] Starting the daemon, user=$jackd_user args=\"$jackd_args\"" >> /var/log/${name}.log |
30 |
# daemon(8) should be able to set the realtime priority, but it isn't |
73 |
daemon -p /var/run/${name}.pid -u "$jackd_user" %%PREFIX%%/bin/jackd $jackd_args |
31 |
$rt daemon -p /var/run/${name}.pid -u "${jackd_user}" %%PREFIX%%/bin/jackd ${jackd_args} |
|
|
32 |
} |
74 |
} |
33 |
|
75 |
|
34 |
load_rc_config ${name} |
76 |
load_rc_config ${name} |