Jump to content

OrangePi as iTunes server with forked-daapd


Recommended Posts

If you follow https://github.com/ejurgensen/forked-daapd you will get a lot of error-messages. 

 

Here is guide to install it on your Orange Pi Pc (Debian Jessie),

sudo apt-get install build-essential git autotools-dev autoconf libtool gettext gawk gperf \
  antlr3 libantlr3c-dev libconfuse-dev libunistring-dev libsqlite3-dev \
  libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavutil-dev \
  libasound2-dev libmxml-dev libgcrypt11-dev libavahi-client-dev zlib1g-dev \
  libevent-dev

for Armbian you need some little extras installed

sudo apt-get install libcurl4-gnutls-dev 
sudo apt-get install libjson0 libjson0-dev
sudo apt-get install avahi-daemon avahi-discover libnss-mdns

then you run

 git clone https://github.com/ejurgensen/forked-daapd.git
 cd forked-daapd
 autoreconf -i
 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
 make
 sudo make install

create the new user 

sudo adduser daapd

adjust the settings for your music-path in /etc/forked-daapd.conf

 

 on my Orange Pi, the file /etc/init.d/forked-daapd was missing. If yours is missing, too, just add it:

sudo nano /etc/init.d/forked-daapd

and copy this text inside:

#! /bin/sh

### BEGIN INIT INFO
# Provides:          forked-daapd
# Required-Start:    $local_fs $remote_fs $network $time avahi
# Required-Stop:     $local_fs $remote_fs $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: media server with support for RSP, DAAP, DACP and AirTunes
# Description:       forked-daapd is an iTunes-compatible media server for
#                    sharing your music library over the local network with RSP
#                    clients like the SoundBridge from Roku and DAAP clients like
#                    iTunes. It can also stream music to AirTunes devices.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/forked-daapd
NAME=forked-daapd
DESC="RSP and DAAP media server"

test -x $DAEMON || exit 0

PIDFILE=/var/run/$NAME.pid

set -e

running_pid()
{
    # Check if a given process pid's cmdline matches a given name
    pid=$1
    name=$2
    [ -z "$pid" ] && return 1
    [ ! -d /proc/$pid ] &&  return 1
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
    # Is this the expected child?
    [ "$cmd" != "$name" ] &&  return 1
    return 0
}

running()
{
# Check if the process is running looking at /proc
# (works for all users)

    # No pidfile, probably no daemon present
    [ ! -f "$PIDFILE" ] && return 1
    # Obtain the pid and check it against the binary name
    pid=`cat $PIDFILE`
    running_pid $pid $DAEMON || return 1
    return 0
}

force_stop() {
# Forcefully kill the process
    [ ! -f "$PIDFILE" ] && return
    if running ; then
        kill -15 $pid
        # Is it really dead?
        if running ; then
            kill -9 $pid
            if running ; then
                echo "Cannot kill $NAME (pid=$pid)!"
                exit 1
            fi
        fi
    fi
    rm -f $PIDFILE
    return 0
}

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
            --exec $DAEMON -- $DAEMON_OPTS
        if running ; then
            echo "$NAME."
        else
            echo " ERROR."
        fi
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
            --exec $DAEMON
        echo "$NAME."
        ;;
  force-reload)
        start-stop-daemon --stop --test --quiet --pidfile \
            /var/run/$NAME.pid --exec $DAEMON \
            && $0 restart \
            || exit 0
        ;;
  restart)
        PID=$(cat $PIDFILE 2> /dev/null || true)

        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --oknodo --pidfile \
            /var/run/$NAME.pid --exec $DAEMON

        if [ -n "$PID" ]; then
            while running_pid $PID $DAEMON; do echo -n "."; sleep 1; done
        fi

        start-stop-daemon --start --quiet --pidfile \
            /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  status)
    echo -n "$NAME is "
    if running ;  then
        echo "running"
    else
        echo " not running."
        exit 1
    fi
    ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0

Save it. 

 

Now we need to allow the service access to it´s own database:

sudo chown -R daapd /var/cache/forked-daapd 

Start the service:

sudo /etc/init.d/forked-daapd restart
tail -f /var/log/forked-daapd.log

you should see some activity on the log-file. After the scanning is complete, you can see your Orange Pi music-server in iTunes.

 

Automatic updates for the music-server (e.g. at 4am in the morning, necessary if you use a network-share for the data):

sudo crontab -e

and add the line

0 4 * * * touch /{path to your music}/trigger.init-rescan
Link to comment
Share on other sites

compile failed ... any idea?

 

~/Downloads/forked-daapd$ make
make  all-recursive
make[1]: Entering directory '/home/pi/Downloads/forked-daapd'
Making all in sqlext
make[2]: Entering directory '/home/pi/Downloads/forked-daapd/sqlext'
/bin/bash ../libtool  --tag=CC   --mode=link gcc  -g -O2 -Wall -D_LARGEFILE_SOURCE -avoid-version -module -shared -lprotobuf-c -o forked-daapd-sqlext.la -rpath /usr/lib/forked-daapd sqlext.lo -lunistring -lpthread
libtool: link: gcc -shared  -fPIC -DPIC  .libs/sqlext.o   -lprotobuf-c -lunistring -lpthread  -O2   -Wl,-soname -Wl,forked-daapd-sqlext.so -o .libs/forked-daapd-sqlext.so
/usr/bin/ld: cannot find -lprotobuf-c
collect2: error: ld returned 1 exit status
Makefile:435: recipe for target 'forked-daapd-sqlext.la' failed
make[2]: *** [forked-daapd-sqlext.la] Error 1
make[2]: Leaving directory '/home/pi/Downloads/forked-daapd/sqlext'
Makefile:534: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/pi/Downloads/forked-daapd'
Makefile:401: recipe for target 'all' failed
make: *** [all] Error 2
 
Link to comment
Share on other sites

I have also this warning below during ./configure
Not sure whether this is related to the error?

 

 

configure: WARNING:
***
*** The config script /usr/bin/libgcrypt-config was
*** built for arm-unknown-linux-gnueabihf and thus may not match the
*** used host armv7l-unknown-linux-gnueabihf.
*** You may want to use the configure option --with-libgcrypt-prefix
*** to specify a matching config script.
***
checking for gpg-error-config... /usr/bin/gpg-error-config
checking for GPG Error - version >= 1.6... yes (1.17)
configure: WARNING:
***
*** The config script /usr/bin/gpg-error-config was
*** built for arm-unknown-linux-gnueabihf and thus may not match the
*** used host armv7l-unknown-linux-gnueabihf.
*** You may want to use the configure option --with-gpg-error-prefix
*** to specify a matching config script or use $SYSROOT.
***
Link to comment
Share on other sites

 

found issue related to --enable-chromecast

my configure script :

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-chromecast 
 
any idea what's missing here to enable chromecast?

 

 

for chromecast you should try 

sudo apt-get install libjson-c-dev libgnutls-dev libprotobuf-c-dev

first. Then try to compile again.

Link to comment
Share on other sites

is it possible to do autorun in systemd ??

cannot start with below /etc/systemd/system/forked-daapd.service

===============================================

 

[unit]
Description=DAAP/DACP (iTunes), RSP and MPD server, supports AirPlay and Remote
After=network.target sound.target
 
[service]
ExecStart=/usr/sbin/forked-daapd -f
 
# Restart, but not more than once every 10 minutes
Restart=on-failure
StartLimitBurst=2
StartLimitInterval=600
 
[install]
WantedBy=multi-user.target
 
Link to comment
Share on other sites

Script from #8 really works.

sudo nano /etc/systemd/system/forked-daapd.service

and paste the script from #8. 

sudo chmod +x forked-daapd.service
sudo systemctl enable forked-daapd.service
sudo systemctl start forked-daapd.service

after that continue from 

tail -f /var/log/forked-daapd.log

from #1.

 

I checked it on my OrangePi Zero with Armbian / Ubuntu Image 

Link to comment
Share on other sites

Is there a reason for you to compile it yourself? I've been using the version from the official packages for quite a while now. I remember there were problems long time ago with version 0.19. But since Espen Jurgensen took over the development (from forked-daapd >= 0.20) this works very reliable. Installation from the official repos is really easy...

 

Debian:

https://packages.debian.org/forked-daapd

 

Ubuntu:

http://packages.ubuntu.com/forked-daapd

Link to comment
Share on other sites

Is there a reason for you to compile it yourself? I've been using the version from the official packages for quite a while now. I remember there were problems long time ago with version 0.19. But since Espen Jurgensen took over the development (from forked-daapd >= 0.20) this works very reliable. Installation from the official repos is really easy...

 

when i tried to use forked-daapd for the first time, it just didn´t work with my iTunes (OS X and Windows 7). Later I found, that Apple changed some small parts of their software :)

Getting the most up-to-date version of forked-daapd solved the problem. And it was just available from source.

 

The developer is very active, so I always have a very good change to solve any kind of problem just by compiling myself.

Link to comment
Share on other sites

for Armbian you need some little extras installed

 

You should be a bit more specific which distro you use. Armbian images were either Debian Wheezy, Jessie, Ubuntu Trusty or Xenial (support for Wheezy and Trusty removed a few hours ago). Usually Ubuntu images are more up to date (and sometimes faster since built with a more recent GCC version). So please add for which distro your instructions should apply.

Link to comment
Share on other sites

You should be a bit more specific which distro you use. Armbian images were either Debian Wheezy, Jessie, Ubuntu Trusty or Xenial (support for Wheezy and Trusty removed a few hours ago). Usually Ubuntu images are more up to date (and sometimes faster since built with a more recent GCC version). So please add for which distro your instructions should apply.

 

Edited the first post and added the information.

Link to comment
Share on other sites

I have problem now playing from local audio output alsa

I want to play from card 1 : snddaudio

Anybody help?

 

/etc/forked-daapd.conf

----------------------------------------------------------------------------

# Local audio output
audio {
        # Name - used in the speaker list in Remote
        nickname = "BPi-M2P"
 
        # Type of the output (alsa, pulseaudio or dummy)
        type = "alsa"
 
        # Audio PCM device name for local audio output - ALSA only
        #card = "default"
        card = "snddaudio"
 
        # Mixer channel to use for volume control - ALSA only
        # If not set, PCM will be used if available, otherwise Master.
#       mixer = ""
 
        # Mixer device to use for volume control - ALSA only
        # If not set, the value for "card" will be used.
#       mixer_device = ""
 
        # Syncronization
        # If your local audio is out of sync with AirPlay, you can adjust this
        # value. Positive values correspond to moving local audio ahead,
        # negative correspond to delaying it. The unit is samples, where is
        # 44100 = 1 second. The offset must be between -44100 and 44100.
#       offset = 0
}
 
 
/var/log/forked-daapd.log
----------------------------------
.....
[2017-01-13 00:45:34] [  LOG]   laudio: Unknown PCM snddaudio[2017-01-13 00:45:34] [  LOG]   laudio: Could not open playback device: No such file or directory
[2017-01-13 00:45:34] [  LOG]   player: Could not start ALSA device 'BPi-M2P'
[2017-01-13 00:45:34] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'
 
 
aplay -l

-----------------------------------

**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: snddaudio [snddaudio], device 0: SUNXI-TDM0 snddaudio-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0
Link to comment
Share on other sites

still error if change

card = "hw:1,0"

 

/var/log/forked-daapd.log

-----------------------------------

[2017-01-13 01:04:47] [  LOG]   laudio: Invalid value for card[2017-01-13 01:04:47] [  LOG]   laudio: Could not open playback device: No such file or directory
[2017-01-13 01:04:47] [  LOG]   player: Could not start ALSA device 'BPi-M2P'
[2017-01-13 01:04:47] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'
Link to comment
Share on other sites

I took the according name from the output of amixer and it works on my Banana Pi running Armbian Debian Jessie.

 

As example:

Excerpt from output of command "amixer":

Simple mixer control 'Power Amplifier',0
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 63
  Mono: Playback 40 [63%] [-23.00dB]
Excerpt of my forked-daapd.conf:

# Localaudio output
audio {
  # Name - used in the speaker list in Remote
  nickname = "My Nickname"
  # Audio device name for local audio output
  # card = "default"
  # Mixer channel to use for volume control - ALSA/Linux only
  # If not set, PCM will be used if available, otherwise Master.
  mixer = "Power Amplifier"
}
Hope that works for you as well.

Cheers.

 

Edit: forked-daapd from official debian-jessie-repo (installed with: "apt-get install forked-daapd", version 22.0-2)

Link to comment
Share on other sites

I have Banana Pi M2+ and use PCM5102 DAC via I2S

So far I know PCM5102 doesn't have digital mixer to control volume

"amixer" output below, no mixer for PCM ??

 

==================================================

Simple mixer control 'Lineout volume control',0

  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 31
  Mono: 31 [100%]
Simple mixer control 'ADC input gain ctrl',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 3 [43%]
Simple mixer control 'Audio adda drc',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Audio adda loop',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Audio linein in',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Audio lineout',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'LINEIN_G boost stage output mixer control',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 3 [43%]
Simple mixer control 'MIC1 boost AMP gain control',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 4 [57%]
Simple mixer control 'MIC1_G boost stage output mixer control',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 3 [43%]
Simple mixer control 'MIC2 boost AMP gain control',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 4 [57%]
Simple mixer control 'MIC2_G boost stage output mixer control',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 3 [43%]
Simple mixer control 'audio capture mode',0
  Capabilities: enum
  Items: 'main mic' 'mic1_2' 'linein'
  Item0: 'main mic'
Link to comment
Share on other sites

amixer --card 1

-----------------------------------------------------------------------------------

Simple mixer control 'I2s Or Pcm Audio Mode Select format',0

  Capabilities: pswitch pswitch-joined

  Playback channels: Mono

  Mono: Playback [on]

 

Change in /etc/forked-daapd.conf

.....

mixer = "I2s Or Pcm Audio Mode Select format"

 

 


/var/log/forked-daapd.log


-----------------------------------




[2017-01-14 22:31:03] [  LOG]   laudio: Failed to open configured mixer element 'I2s Or Pcm Audio Mode Select format'

[2017-01-14 22:31:03] [  LOG]   laudio: Could not open mixer

[2017-01-14 22:31:03] [  LOG]   player: Could not start ALSA device 'BPi-M2P'

[2017-01-14 22:31:03] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'

 

Link to comment
Share on other sites

This doesn't work?

card = "hw:1"
mixer = "I2s Or Pcm Audio Mode Select format"

 

/var/log/forked-daapd.log

---------------------------------

[2017-01-15 00:05:54] [  LOG]   laudio: open '/dev/snd/pcmC1D0p' failed (-16)[2017-01-15 00:05:54] [  LOG]   laudio: Could not open playback device: Device or resource busy
[2017-01-15 00:05:54] [  LOG]   player: Could not start ALSA device 'BPi-M2P'
[2017-01-15 00:05:54] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'
Link to comment
Share on other sites

Device or resource busy

This looks like forked-daapd is trying to access the correct device, but there is another service/application running which accesses and thus blocks the audio device - or another application was running which used the audio device and didn't free the access again after using that audio-device.

 

Do you have an idea what that could be? Try to disable it (or maybe reboot) and then try again with forked-daapd.

 

I think we found the correct card and mixer. But with the "device or resource busy" problem I can't help any further. This you need to figure out yourself. Good luck :-)

Link to comment
Share on other sites

This looks like forked-daapd is trying to access the correct device, but there is another service/application running which accesses and thus blocks the audio device - or another application was running which used the audio device and didn't free the access again after using that audio-device.

 

Do you have an idea what that could be? Try to disable it (or maybe reboot) and then try again with forked-daapd.

 

I think we found the correct card and mixer. But with the "device or resource busy" problem I can't help any further. This you need to figure out yourself. Good luck :-)

 

shairport-sync is using this audio device

however i didn't hard lock the device, instead i'm using .asoundrc in /home/shairport-sync

my understanding by doing this, hw:1,0 can be switched, activated upon usage selection, but seems it's not the case

do you know anyway to share same device by multiple application?

Link to comment
Share on other sites

dmix if we are talking about ALSA, otherwise pulseaudio can do this too.

http://alsa.opensrc.org/Dmix

https://www.alsa-project.org/main/index.php/Asoundrc#dmix

 

I do have already enable dmixer in .asoundrc

Am I missing something?

 

.asoundrc

-----------------------------------------------------------

pcm.snd_card {
        type hw
        card 1
        device 0
}
 
ctl.snd_card {
        type hw
        card 1
        device 0
}
 
pcm.dmixer {
    type dmix
    ipc_key 1024
    ipc_perm 0666
    slave.pcm snd_card
    slave {
        period_time 0
        period_size 1024
        buffer_size 4096
        rate 44100
        format S32_LE
        channels 2
    }
    bindings {
        0 0
        1 1
    }
}
Link to comment
Share on other sites

Yes, you need to set it as a default ALSA input or you need to tell your applications to use dmix explicitly (instead of "hw:1" it should be something like "plug:dmix" if I remember correctly.

 

 I change .asoundrc to this below, but still not working

-----------------------------------------------------------------------

pcm.!default {

    type plug

    slave.pcm "dmixer"

}

 

pcm.dmixer {

    type dmix

    ipc_key 1024

    slave {

        pcm "hw:1,0"

        period_time 0

        period_size 1024

        buffer_size 4096

        rate 44100

    }

    bindings {

        0 0

        1 1

    }

}

 

ctl.dmixer {

    type hw

    card 1

}

Link to comment
Share on other sites

But you are still telling your applications to use "hw:1" directly and thus bypassing the dmix. If your default configuration is correct, you should be able to use something like "plug:default" in applications too.

 

/var/log/forked-daapd.log

-------------------------------

[2017-01-16 02:27:51] [  LOG]   laudio: Invalid CTL plug:dmix[2017-01-16 02:27:51] [  LOG]   laudio: Failed to attach mixer: No such file or directory
[2017-01-16 02:27:51] [  LOG]   laudio: Could not open mixer
[2017-01-16 02:27:51] [  LOG]   player: Could not start ALSA device 'BPi-M2P'
[2017-01-16 02:27:51] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'
 
Link to comment
Share on other sites

change card = "plug:default"

 

/var/log/forked-daapd.log

-------------------------------

[2017-01-16 02:29:33] [  LOG]   laudio: Invalid CTL plug:default[2017-01-16 02:29:33] [  LOG]   laudio: Failed to attach mixer: No such file or directory
[2017-01-16 02:29:33] [  LOG]   laudio: Could not open mixer
[2017-01-16 02:29:33] [  LOG]   player: Could not start ALSA device 'BPi-M2P'
[2017-01-16 02:29:33] [  LOG]   player: Could not activate ALSA device 'BPi-M2P'
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines