diff --git a/audio/jack/Makefile b/audio/jack/Makefile index 49efc4daf81a..f8eeea1cf31e 100644 --- a/audio/jack/Makefile +++ b/audio/jack/Makefile @@ -1,7 +1,7 @@ PORTNAME= jackit DISTVERSIONPREFIX= v DISTVERSION= 1.9.22 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= audio MAINTAINER= dev@submerge.ch diff --git a/audio/jack/files/jackd.in b/audio/jack/files/jackd.in index 9f135a6c8f1b..1c71d71e337d 100644 --- a/audio/jack/files/jackd.in +++ b/audio/jack/files/jackd.in @@ -10,8 +10,8 @@ : ${jackd_enable="NO"} : ${jackd_user="root"} -: ${jackd_rtprio="NO"} -: ${jackd_args="-r -doss -r44100 -p1024 -n3 -w16"} +: ${jackd_rtprio="YES"} +: ${jackd_args="-doss -r48000 -p1024 -w16"} . /etc/rc.subr @@ -20,15 +20,57 @@ rcvar=jackd_enable procname=%%PREFIX%%/bin/jackd start_cmd="start_jackd" +fail() { + echo "JACK failed to start: $1" >&2 + exit 1 +} + start_jackd() { echo "Starting ${name}." - if [ $jackd_rtprio = "YES" ]; then - local rt="rtprio 1" + + # check that jackd_user is set + if [ -z "$jackd_user" ]; then + fail "jackd_user has to be defined" + fi + + # check that jackd_args doesn't contain -R, or -r because we explicitly set them below + if echo $jackd_args | grep -qw -- "-R"; then + fail "jackd_args contains -R which isn't allowed: it is set automatically only when needed" + fi + if echo $jackd_args | sed -e 's/-r *[0-9]/xxx/g' | grep -qw -- "-r"; then # allow -r rate, but not just -r + fail "jackd_args contains -r which isn't allowed: it is set automatically only when needed" + fi + + # enable real-time priority if requested + if [ "$jackd_rtprio" = "YES" ]; then + # check that mac_priority(4) is enabled + if [ "$(sysctl -qn security.mac.priority.realtime)" != "1" ]; then + fail "jackd_rtprio=\"YES\" but mac_priority(4) isn't enabled on this system" + fi + # check that the group 'realtime' exists + if ! getent group realtime > /dev/null; then + fail "jackd_rtprio=\"YES\" but the group 'realtime' doesn't exist" + fi + # check that the user is in the realtime group + if ! (getent group realtime | grep -qw "$jackd_user"); then + fail "jackd_rtprio=\"YES\" but the user jackd_user=$jackd_user isn't in the realtime group" + fi + + # enable the real-time priority functionality in JACK + jackd_args="-R $jackd_args" + else + echo "Warning: The real-time priority feature is disabled by jackd_rtprio=${jackd_rtprio}." + echo " For real-time priority:" + echo " (1) enable mac_priority(4) on the system by adding mac_priority_load=\"YES\" to loader.conf" + echo " (2) add the user jackd_user=$jackd_user to the group 'realtime'" + echo " (3) set jackd_rtprio=\"YES\"" + + # enable the non-real-time priority functionality in JACK + jackd_args="-r $jackd_args" fi # log the date and parameters - echo -e "\n[`date`] Starting the daemon, user=$jackd_user rtprio=$jackd_rtprio args=\"$jackd_args\"" >> /var/log/${name}.log - # daemon(8) should be able to set the realtime priority, but it isn't - $rt daemon -p /var/run/${name}.pid -u "${jackd_user}" %%PREFIX%%/bin/jackd ${jackd_args} + echo -e "\n[`date`] Starting the daemon, user=$jackd_user args=\"$jackd_args\"" >> /var/log/${name}.log + daemon -p /var/run/${name}.pid -u "$jackd_user" %%PREFIX%%/bin/jackd $jackd_args } load_rc_config ${name} diff --git a/audio/jack/pkg-message b/audio/jack/pkg-message index 2a94946d2d57..fefdba1894af 100644 --- a/audio/jack/pkg-message +++ b/audio/jack/pkg-message @@ -3,11 +3,15 @@ The new JACK server comes with a DBUS control interface: $ jack_control help $ jack_control ds oss $ jack_control dp +$ jack_control dps rate 48000 +$ jack_control dps wordlength 16 +$ jack_control dps capture /dev/dsp0 +$ jack_control dps playback /dev/dsp0 $ jack_control eps realtime False $ jack_control start -Only root can grant real-time priority to processes for now, using rtprio(1). -Upcoming FreeBSD releases will have a MAC policy with a realtime user group. +To use real-time priority for JACK server and clients, load the mac_priority(4) +module and add the JACK user to the realtime group. Memory locking has to be allowed in /etc/login.conf or ~/.login_conf. Set the resource limit ":memorylocked=unlimited:" and don't forget to run @@ -19,8 +23,7 @@ Note that only one JACK server can be run at a time. An /etc/rc.conf example: jackd_enable="YES" jackd_user="joe" -jackd_rtprio="YES" -jackd_args="-R -doss -r48000 -p1024 -n1 -w16 \ +jackd_args="-r -doss -r48000 -p1024 -w16 \ --capture /dev/dsp0 --playback /dev/dsp0" Official JACK example clients and tools are available as jack-example-tools.