Quantcast

Audio device busy running as daemon

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Audio device busy running as daemon

KB1NYT
Hello

Svxlink runs fine from the command line but if I try to run it as a
daemon I get the following error in the log file. The setup is a
Raspberry Pi running Raspbian and a USB sound card. I am using the
daemon script that came with the install slightly modified for the dir
structure here. The only thing I did not add to the script was the audio
strings for start and stop. Svxlink user is part of the audio group. Not
sure what to look for.

thanks
Jay
KB1NYT

Wed Dec 21 11:54:59 2016: SvxLink v1.5.0 Copyright (C) 2003-2015 Tobias
Blomberg / SM0SVX
Wed Dec 21 11:54:59 2016:
Wed Dec 21 11:54:59 2016: SvxLink comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are
Wed Dec 21 11:54:59 2016: welcome to redistribute it in accordance with
the terms and conditions in the
Wed Dec 21 11:54:59 2016: GNU GPL (General Public License) version 2 or
later.
Wed Dec 21 11:54:59 2016:
Wed Dec 21 11:54:59 2016: Using configuration file:
/opt/svxlink/etc/svxlink/svxlink.conf
Wed Dec 21 11:54:59 2016: --- Using sample rate 48000Hz
Wed Dec 21 11:54:59 2016:
Wed Dec 21 11:54:59 2016: Starting logic: SimplexLogic
Wed Dec 21 11:54:59 2016: Loading RX: Rx1
Wed Dec 21 11:54:59 2016: *** ERROR: Open capture audio device failed:
Device or resource busy
Wed Dec 21 11:54:59 2016: *** ERROR: Could not open audio device for
receiver "Rx1"
Wed Dec 21 11:54:59 2016: *** ERROR: Could not initialize RX "Rx1"
Wed Dec 21 11:54:59 2016: *** ERROR: Could not initialize Logic object
"SimplexLogic". Skipping...
Wed Dec 21 11:54:59 2016: *** ERROR: No logics available. Bailing out...


#!/bin/sh
# Debian like server start/stop script, developed for raspbian distro
# Copyright (c) 2013-2014 - F1RMB, Daniel Caujolle-Bert
<[hidden email]>
# Licended under GPL v2 or later

#
# /etc/default/svxlink support following options:
#
  GPIO_PTT_PIN=23
#     <num> defines the GPIO pin used for PTT.
  GPIO_SQL_PIN=27
#     <num> defines the GPIO pin used for Squelch.
#
# AUDIO_SETTINGS_ONSTART="<string>"
# AUDIO_SETTINGS_ONSTOP="<string>"
#     <string>: shell script command(s)
#

### BEGIN INIT INFO
# Provides:        svxlink
# Required-Start:  $local_fs $remote_fs $syslog $network $ntp
# Required-Stop:   $local_fs $remote_fs
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start svxLink Server daemon
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /lib/lsb/init-functions

PROG="svxlink"
DAEMON=/opt/svxlink/bin/$PROG
#DAEMON=/usr/bin/$PROG
PIDFILE=/var/run/$PROG.pid
LOCKFILE=/var/lock/$PROG
LOGFILE=/var/log/$PROG
RUNASUSER=svxlink

test -x $DAEMON || exit 5

if [ -r /etc/default/$PROG ]; then
     . /etc/default/$PROG
fi

UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
SVXLINK_OPTS="--daemon ${LOGFILE:+--logfile=$LOGFILE}
${CFGFILE:+--config=$CFGFILE} --runasuser=$RUNASUSER --pidfile=$PIDFILE"

lock_svxlink() {
     if [ -x /usr/bin/lockfile-create ]; then
         lockfile-create $LOCKFILE
         lockfile-touch $LOCKFILE &
         LOCKTOUCHPID="$!"
     fi
}

unlock_svxlink() {
     if [ -x /usr/bin/lockfile-create ] ; then
         kill $LOCKTOUCHPID
         lockfile-remove $LOCKFILE
     fi
}

gpio_setup() {
    NAME=$1
    PIN=$2
    DIR=$3
    if [ ! -z "$PIN" -a ! -e /sys/class/gpio/gpio$PIN ]; then
        # Enable the pin for GPIO:
        log_progress_msg "[GPIO $NAME #$PIN"
        echo $PIN > /sys/class/gpio/export
        # Set the direction to output for the pin:
        log_progress_msg ", direction"
        echo $DIR > /sys/class/gpio/gpio$PIN/direction
        # Make sure that the svxlink user can write to the GPIO pin:
        log_progress_msg ", owner]"
        chown svxlink /sys/class/gpio/gpio$PIN/value
    fi
}

gpio_unsetup() {
    NAME=$1
    PIN=$2
    if [ ! -z "$PIN" -a -e /sys/class/gpio/gpio$PIN ]; then
        log_progress_msg "[GPIO $NAME #$PIN]"
        # Enable the pin for GPIO:
        echo $PIN > /sys/class/gpio/unexport
    fi
}

case "$1" in
     start)
     log_daemon_msg "Starting SVXLINK server" "svxlink"

     ## Check if svxlink user exists
     if [ -z "$UGID" ]; then
         log_failure_msg "user \"$RUNASUSER\" does not exist"
         exit 1
     fi

     lock_svxlink

     ## Check about pid file
     if [ -e $PIDFILE ]; then
         if $0 status > /dev/null ; then
         log_failure_msg "$PROG is already started; not starting"
         return
         else
         log_progress_msg "[Removing stale PID file $PIDFILE]"
         rm -f $PIDFILE
         fi
     fi

     ## GPIO PTT support ?
     if [ ! -z "$GPIO_PTT_PIN" ]; then
         gpio_setup PTT $GPIO_PTT_PIN out
     fi

     ## GPIO SQL support ?
     if [ ! -z "$GPIO_SQL_PIN" ]; then
         gpio_setup SQL $GPIO_SQL_PIN in
     fi

     ## Audio settings on startup ?
     if [ ! -z "$AUDIO_SETTINGS_ONSTART" ]; then
         log_progress_msg ", audio"
         eval $AUDIO_SETTINGS_ONSTART > /dev/null 2<&1
     fi

     ## Start the daemon
     start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE
--startas $DAEMON -- $SVXLINK_OPTS
     status=$?

     unlock_svxlink

     log_end_msg $status
         ;;

     stop)
     log_daemon_msg "Stopping SVXLINK server" "svxlink"

     ## Stopping the daemon
       start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE

     ## Audio settings on leaving ?
     if [ ! -z "$AUDIO_SETTINGS_ONSTOP" ]; then
         log_progress_msg ", unsetting audio"
         eval $AUDIO_SETTINGS_ONSTOP > /dev/null 2<&1
     fi

     ## Unset GPIO PTT pin, if used
     if [ ! -z "$GPIO_PTT_PIN" ]; then
         gpio_unsetup PTT $GPIO_PTT_PIN
     fi

     ## Unset GPIO SQL pin, if used
     if [ ! -z "$GPIO_SQL_PIN" ]; then
         gpio_unsetup SQL $GPIO_SQL_PIN
     fi

     log_end_msg $?
     rm -f $PIDFILE
         ;;

     restart|force-reload)
     $0 stop && sleep 2 && $0 start
       ;;

     try-restart)
     if $0 status >/dev/null; then
         $0 restart
     else
         exit 0
     fi
     ;;

     reload)
     exit 3
     ;;

     status)
     status_of_proc $DAEMON "SVXLINK server"
     ;;

     gpio)
     # PTT
     if [ ! -z "$GPIO_PTT_PIN" -a ! -e /sys/class/gpio/gpio$GPIO_PTT_PIN
]; then
         log_daemon_msg "Initialize PTT GPIO" "gpio$GPIO_PTT_PIN"
         gpio_setup PTT $GPIO_PTT_PIN out
     else
         log_daemon_msg "Uninitialize PTT GPIO" "gpio$GPIO_PTT_PIN"
         gpio_unsetup PTT $GPIO_PTT_PIN
     fi
     log_end_msg 0

     ## Squelch
     if [ ! -z "$GPIO_SQL_PIN" -a ! -e /sys/class/gpio/gpio$GPIO_SQL_PIN
]; then
         log_daemon_msg "Initialize Squelch GPIO" "gpio$GPIO_SQL_PIN"
         gpio_setup SQL $GPIO_SQL_PIN in
     else
         log_daemon_msg "Uninitialize Squelch GPIO" "gpio$GPIO_SQL_PIN"
         gpio_unsetup SQL $GPIO_SQL_PIN
     fi
     log_end_msg 0
     ;;

     *)
     echo "Usage: $0
{start|stop|restart|try-restart|force-reload|gpio|status}"
     exit 2
     ;;
esac


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Audio device busy running as daemon

Rob Janssen
Jay wrote:

> Hello
>
> Svxlink runs fine from the command line but if I try to run it as a
> daemon I get the following error in the log file. The setup is a
> Raspberry Pi running Raspbian and a USB sound card. I am using the
> daemon script that came with the install slightly modified for the dir
> structure here. The only thing I did not add to the script was the audio
> strings for start and stop. Svxlink user is part of the audio group. Not
> sure what to look for.
>
> thanks
> Jay
> KB1NYT
>
> Wed Dec 21 11:54:59 2016: SvxLink v1.5.0 Copyright (C) 2003-2015 Tobias
> Blomberg / SM0SVX
> Wed Dec 21 11:54:59 2016:
> Wed Dec 21 11:54:59 2016: SvxLink comes with ABSOLUTELY NO WARRANTY.
> This is free software, and you are
> Wed Dec 21 11:54:59 2016: welcome to redistribute it in accordance with
> the terms and conditions in the
> Wed Dec 21 11:54:59 2016: GNU GPL (General Public License) version 2 or
> later.
> Wed Dec 21 11:54:59 2016:
> Wed Dec 21 11:54:59 2016: Using configuration file:
> /opt/svxlink/etc/svxlink/svxlink.conf
> Wed Dec 21 11:54:59 2016: --- Using sample rate 48000Hz
> Wed Dec 21 11:54:59 2016:
> Wed Dec 21 11:54:59 2016: Starting logic: SimplexLogic
> Wed Dec 21 11:54:59 2016: Loading RX: Rx1
> Wed Dec 21 11:54:59 2016: *** ERROR: Open capture audio device failed:
> Device or resource busy
> Wed Dec 21 11:54:59 2016: *** ERROR: Could not open audio device for
> receiver "Rx1"
> Wed Dec 21 11:54:59 2016: *** ERROR: Could not initialize RX "Rx1"
> Wed Dec 21 11:54:59 2016: *** ERROR: Could not initialize Logic object
> "SimplexLogic". Skipping...
> Wed Dec 21 11:54:59 2016: *** ERROR: No logics available. Bailing out...
>

It looks like some other software has the device open at the time you start the service.
Make sure the commandline version is not running and that no other software that tries
to open te audio device (including any "sound daemon" like pulseaudio) is running.

Rob

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Audio device busy running as daemon

David Ranch-3

It looks like some other software has the device open at the time you start the service.
Make sure the commandline version is not running and that no other software that tries
to open te audio device (including any "sound daemon" like pulseaudio) is running.

It wasn't mentioned which OS is running on the Raspberry Pi but I'm assuming Wheezy as this isn't a Systemd-type startup script.  Make sure that:

1. the svxlink user has been created
2. the svxlink user does NOT have a password (don't allow logins for this user)
3. the svxlink user is in the "audio" unix group
4. the svxlink user is in the "gpio" unix group

If you had to add any of the above, reboot the rpi before trying to start Svxlink as a service.

If that still doesn't work, see if you can run "sudo su - svxlink" and become the svxlink user.  From there, try starting Svxlink and see if it works or not.


Btw, I have a bunch of these setup steps for the Raspberri Pi which also includes hardening, security, etc. if you find it helpful.  It's intended for the Direwolf packet program but everything before that might provide you some ideas.

   http://www.trinityos.com/HAM/CentosDigitalModes/RPi/rpi2-setup.html

--David
KI6ZHD

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Loading...