Press "Enter" to skip to content

Autore: Simone

Logitech Media Server and FreeBSD

There are 3 ways to install Logitech Media Server on you FreeBSD computer: ports, packages and DIY (yes … you have to compile everything)

Ports

Just type:

pkg install portmaster
portmaster audio/logitechmediaserver

IMPORTANT: while configuring the options of all softwares you are going to install, when logitechmediaserver options will be prompted make sure that “TEST” will NOT be ticked.

Note that the last update of this port was at the 11th July 2017.

Packages

I have personally built packages from the ports because an LMS package is not available; due to this you have to add my repository to the package manager configuration file:

ee /etc/pkg/FreeBSD.conf

and add

audiodigitale: {
url: "http://audiodigitale.eu/repo/freebsd/pkgs",
mirror_type: "http",
enabled: yes
}

then you can:

pkg update
pkg install logitechmediaserver

Note that the last update was at the 6th January 2018.

DIY, aka: compile everything from source

Before starting this is what you need:

  • libtime.a
  • libpatience.a
  • Knowledges about what are jails (I will use CBSD to manage them)

Let’s start creating a jail that we will use to build everything:

cbsd jconstruct-tui

In “pkglist” insert manually:

unzip bash gmake rsync nasm wget libgd gcc perl5-5.24.1 automake libtool

Enter in the jail:

cbsd jstart build
cbsd jlogin build

I’m going to use /tmp to download everything and build lms:

cd /tmp
wget http://downloads.slimdevices.com/nightly/7.9/sc/3adb1b4/logitechmediaserver-7.9.1-1489743085.tgz
wget https://github.com/Logitech/slimserver-vendor/archive/public/7.9.zip
unzip 7*
tar xjf l*

Let’s start compiling:

cd slimserver-vendor-public-7.9/CPAN
./buildme.sh -t | tee /tmp/build.log
cd /tmp/logitechmediaserver-7.9.1-1489743085/CPAN/arch/5.24
rm -rf 5.1* && rm -rf 5.8 && rm -rf 5.22 && rm -rf 5.20
cp -Rp /tmp/slimserver-vendor-public-7.9/CPAN/build/arch/5.24/amd64-freebsd-thread-multi .
rm -rf x*

cd /tmp
tar cf FreeBSD-lms-7.9.1.tar logitechmediaserver-7.9.1-1489743085

wget http://downloads.xiph.org/releases/flac/flac-1.3.2.tar.xz
tar xf f*
cd flac-1.3.2
autoreconf -i
./configure --enable-static --disable-shared
make

cd /tmp
wget http://downloads.sourceforge.net/faac/faad2-2.7.zip
unzip faad2-2.7.zip
cd faad2-2.7
./configure --enable-static --disable-shared
make

cd /tmp
wget http://www.wavpack.com/wavpack-5.1.0.tar.bz2
tar xf wavpack-5.1.0.tar.bz2
cd wavpack-5.1.0
autoreconf -i
./configure --enable-static --disable-shared
make

Now we have to exit from this jail and move everything we have just compiled to a new jail when logitechmediaserver will run.

First of all exit from the build jail:

exit

Create a new jail like we did before including the following packages:

wget perl5-5.24.1 libiconv

cbsd jstart lms
mv /usr/jails/jails-data/build-data/tmp/FreeBSD-lms-7.9.1.tar /usr/jails/jails-data/lms-data/tmp
cbsd jlogin lms

Now I’m going to copy lms and the binaries we have compile above in the “lms” jail. I will include the modified version of SoX able to convert in DSD; for further info: Logitechmediaserver, C-3PO and PCM to DSD conversion

cd /tmp
tar xf F*
pw groupadd -n lms -g 20000
pw useradd -n lms -u 20000 -g lms -s /usr/sbin/nologin -c "Logitech Media Server" -d /nonexistent
mkdir /usr/local/lms
mv logitechmediaserver-7.9.1-1489743085 /usr/local/lms/
cd /usr/local/lms
mv logitechmediaserver-7.9.1-1489743085/* /usr/local/lms
rmdir logitechmediaserver-7.9.1-1489743085
rm -rf Bin/a* && rm -rf Bin/i* && rm -rf Bin/p* && rm -rf Bin/s* && rm -rf Bin/x*
cd Bin
wget https://audiodigitale.eu/repo/sox/sox-FreeBSD
mv sox-FreeBSD sox

exit

Move flac, faad, wavpack binaries into the Bin folder of LMS:

mv /usr/jails/jails-data/build-data/tmp/flac-1.3.2/src/flac/flac /usr/jails/jails-data/lms-data/usr/local/lms/Bin/
mv /usr/jails/jails-data/build-data/tmp/faad2-2.7/frontend/faad /usr/jails/jails-data/lms-data/usr/local/lms/Bin/
mv /usr/jails/jails-data/build-data/tmp/wavpack-5.1.0/cli/wvunpack /usr/jails/jails-data/lms-data/usr/local/lms/Bin/

Back into lms jail:

cbsd jlogin lms
chown -R lms:lms /usr/local/lms
chmod -R 755 /usr/local/lms/Bin
mkdir /var/log/lms
mkdir /var/db/lms
mkdir /var/db/lms/cache
mkdir /var/db/lms/prefs
mkdir /var/db/lms/playlists
chown -R lms:lms /var/db/lms
chown -R lms:lms /var/log/lms
cd /etc/rc.d
wget https://audiodigitale.eu/repo/freebsd/lms
chmod 555 lms
echo 'lms_enable="YES"' >> /etc/rc.conf && echo 'lms_logdir="/var/log/lms"' >> /etc/rc.conf && echo 'lms_cachedir="/var/db/lms/cache"' >> /etc/rc.conf && echo 'lms_prefsdir="/var/db/lms/prefs"' >> /etc/rc.conf && echo 'lms_playlistdir="/var/db/lms/playlists"' >> /etc/rc.conf

exit

Now restart the jail and Logitech Media Server will start at boot (if you are lucky 😉 )

cbsd jstop lms
cbsd jstart lms

How to compile Squeezelite-R2

In the download area you can find the .tar.gz archives of the source code used to compile binaries available for download on this website:

  • squeezelite-R2_FULL.tar.gz this is the same source code available in the github repository linked below. Compatible with all O.S.
  • squeezelite-R2_Unix.tar.gz this is the source code compatible only with Unix based system, recommended for building in macOS, FreeBSD and ARM devices.

IMPORTANT: the github repository with updated source code and more information about the project is as always at marcoc1712/squeezelite-R2

Linux

IMPORTANT: to correctly stream DSD format you need to have on your O.S. ALSA >= 1.0.29

Those distros are currently (March 2017) compatible:

- Debian: >= 9.0 ("Stretch")
- Ubuntu: >= 16.04
- Mint: >= 18
- Fedora: >= 22
- RHEL e derivate (CentOS, Scientific Linux): >= 6.x
- openSUSE: >= 42.1
- Slackware: >= 14.2
- Arch: current
- Gentoo: current

Install the dependencies:

sudo apt-get install libasound2 libasound2-dev libflac-dev libmad0-dev libfaad-dev libmpg123-dev libvorbis-dev

Compile:

make -f Makefile.debian # or Makefile.linux if you are using the *Unix.tar.gz

RaspberryPi and other SBC

Important: Raspbian is not compatible because it uses an old version of alsa.
Please use a O.S. with alsa >= 1.0.29 such as Ubuntu server 16.10

sudo apt-get install libasound2 libasound2-dev libflac-dev libmad0-dev libfaad-dev libmpg123-dev libvorbis-dev

make -f Makefile.rpi

If you are using RaspberryPi3 with an ARM64 compatible O.S., after installing the dependencies run:

make -f Makefile.rpi_ARM64

macOS

Install brew -> https://brew.sh/

brew install portaudio flac mad faad2 mpg123 libvorbis

make -f Makefile.macOS-64bit

or

make -f Makefile.macOS-32bit

FreeBSD

sudo pkg install portaudio gmake flac libmad faad2 mpg123 libvorbis

gmake -f Makefile.freebsd

RaspberryPi and other SBC

sudo pkg install portaudio gmake flac libmad faad2 mpg123 libvorbis

gmake -f Makefile.raspbsd

If you are using a RaspberryPi3 with an ARM64 compatible O.S. then run:

sudo pkg install portaudio gmake aarch64-binutils flac libmad faad2 mpg123 libvorbis

gmake -f Makefile.raspbsd_ARM64

 

How to compile SoX

In the download area you can find the .tar.gz archives of the source code used to compile the binaries available for download on this website:

  • sox.tar.gz this version has opus support disabled because it causes some problems on macOS and FreeBSD and is therefore compatible with all O.Ss.

IMPORTANT: the GitHub repository with updated source code and more information about this project is as always at mansr/sox

Linux

Every Linux distribution has its own package manager and its own packages, the following applies to Ubuntu but it can easily tweaked to work elsewhere. Install the dependencies first:

sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libao-dev libflac-dev libmp3lame-dev libtwolame-dev libltdl-dev libmad0-dev libid3tag0-dev libvorbis-dev libpng-dev libsndfile1-dev libwavpack-dev

Run the following:

autoreconf -i
./configure
make

If you wish to compile a static linked binary : Coming soon …

FreeBSD

You have three choices to install the dependencies:

1- Download each tarball from its website (only the ones you need) and compile them all:

OpencoreAMR-NB/WB http://sourceforge.net/projects/opencore-amr
AMR-NB/WB http://www.penguin.cz/~utx/amr
AO http://xiph.org/ao
FLAC http://flac.sourceforge.net
LADSPA http://www.ladspa.org
Lame MP3 encoder http://lame.sourceforge.net
Twolame MP2 enc. http://www.twolame.org
libltdl http://www.gnu.org/software/libtool
MAD MP3 decoder http://www.underbit.com/products/mad
MP3 ID3 tags https://sourceforge.net/projects/mad/files/libid3tag/
Magic http://www.darwinsys.com/file
Ogg Vorbis http://www.vorbis.com
Opus http://www.opus-codec.org/
PNG http://www.libpng.org/pub/png zlib
Sndfile http://www.mega-nerd.com/libsndfile
WavPack http://www.wavpack.com

2- Use ports <- Recommended!

audio/opencore-amr
audio/libao
audio/flac
audio/ladspa
audio/lame
audio/twolame
devel/libltdl
audio/libmad
audio/libid3tag
cad/magic
audio/libvorbis
graphics/png
audio/libsndfile
audio/wavpack

3- Use packages <- Fastest

pkg install opencore-amr libao flac ladspa twolame libltdl libmad libid3tag magic libvorbis png libsndfile wavpack

P.S. lame is not included in the package list because you need to compile it from ports.

As you can see I haven’t included opus in the list above due to some issues with this audio codec in O.Ss different from Linux.

Compiling

For a standard configuration:

autoreconf -i
./configure
make

If you want a static linked binary just take all the libraries you compiled before with extension *.a and copy them to a folder ex. /ex/folder and then:

autoreconf -i
./configure CFLAGS='-static' LDFLAGS='-static -L/ex/folder' --disable-shared --with-distro='FreeBSD 11'
make

macOS

Just use Brew -> https://brew.sh/

brew install opencore-amr libao flac two-lame libtool mad libid3tag libmagic libvorbis libpng libsndfile wavpack lame

Compiling

For a standard configuration:

autoreconf -i
./configure
make

If you want a static linked binary just take all the libraries you compiled before with extension *.a and copy them to a folder ex. /ex/folder, then run:

autoreconf -i
./configure LDFLAGS='-static -L/ex/folder' --disable-shared --with-distro='macOS 10.12 Sierra'
make

Logitechmediaserver, C-3PO and PCM to DSD conversion

 

In this tutorial I’m going to illustrate how to implement and enable PCM->DSD conversion on-the-fly on Logitech Media Server. This is possible thanks to the plugin C-3PO and a modified version of SoX and Squeezelite-R2.

For a complete introduction and description of what is Logitech Media Server and how to install and use it you can read this Marco Curti’s guide -> Introduction to Squeezebox Server (translation in English will be available soon)

SOX

First of all we have to substitute the original SoX binary package in LMS with the modified one; go to the directory that contains LMS binaries:

Linux:

cd /usr/share/squeezeboxserver/Bin/ARCH

Where “ARCH” is the architecture of your operative system.

FreeBSD:

cd /usr/local/share/logitechmediaserver/Bin

macOS:

cd /Library/PreferencePanes/Squeezebox.prefPane/Contents/server/Bin/darwin

Windows:

cd C:\Program Files\Squeezebox\server\Bin\MSWin32-x86-multi-thread

Then remove the “old” sox, download the modified one and rename it in “sox”.

*nix O.S.

rm sox && wget https://audiodigitale/repo/sox-VERSION

You can find all the versions of SoX for different O.S. here -> Download SoX

The binaries in the download area are statically linked, so you don’t have to install any dependencies!

If you want to compile SoX by yourself in the download area there is the .tar.gz archive of the same version of SoX used to compile the binaries; otherwise you can also clone this github repository
-> mansr/sox

If you have any doubt follow this guide -> How to compile SoX

NOTE: There is an unresolved bug in MacOS that doesn’t allow C-3PO to recognize the modified version of SoX

C-3PO

To install C-3PO please insert this repository in the lms plugin page :
http://www.marcoc1712.it/downloads/repository.xml

If you want to read more documentation about C-3PO follow this link -> C-3PO Transcoding Helper (translation in English will be available soon)

Project with source code on github -> marcoc1712/C-3PO

Particular instruction for FreeBSD: in this O.S. the directory that contains the binary of perl is different from linux, so you have to modify this file:

/var/db/logitechmediaserver/cache/InstalledPlugins/Plugins/C3PO/Bin/C-3PO

and replace #!/usr/bin/perl with #!/usr/local/bin/perl

Squeezelite-R2

Now your server should be ready to trascode PCM files to DSD, we just need to setup the client:

Please download the correct version for you O.S. here -> Squeezelite-R2

If you don’t know how to use it please read this guide -> Squeezelite-R2 Guide (translation in English will be available soon)

If you want to compile Squeezelite-R2 by yourself in the download area there is the .tar.gz archive of the same version of squeezelite-R2 used to compile the binaries; otherwise you can also clone this github repository -> marcoc1712/squeezelite-R2

If you have any doubt follow this guide -> How to compile Squeezelite-R2

Do you want to install and setup every single option of squeezelite easily? You can do it with Falcon, a practical and user-friendly web interface to manage every aspect of squeezelite! (Only for linux, beta)

Do you already know how to use squeezelite and you just want to start it at boot time?

Init Script (Linux)

sudo nano /etc/init.d/squeezelite

#!/bin/sh
### BEGIN INIT INFO
# Provides: squeezelite
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script per l'avvio di squeezelite
# Description: ---
### END INIT INFO


#VARIABLES

USER=root
OUTPUT= # Specify output device, default -> default, - = output to stdout
NAME= # Set the player name
LMS= # <server>[:<port>]
ALSA= # -a <b>:<p>:<f>:<m> Specify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)
BUFFER= # <stream>:<output> Specify internal Stream and Output buffer sizes in Kbytes
SCHEDULER= # <scheduler>:<rt priority> Scheduler: other, fifo, rr. Priority: 1-99 -> 1 min priority 99 max priority
NICENESS= # nice level -20 max priority 19 min priority

#CODE

case "$1" in
start)
echo "Starting Squeezelite"
start-stop-daemon -S --chuid $USER -N $NICENESS -P $SCHEDULER --exec /squeezelite -- -z -o $OUTPUT -n $NAME -s $LMS -a $ALSA -b $BUFFER -D
;;
stop)
echo "Stopping Squeezelite"
start-stop-daemon -K --name squeezelite
;;
*)
echo "Usage: /etc/init.d/squeezelite {start|stop}"
exit 1
;;
esac
exit

Save the file and:

sudo chmod +x /etc/init.d/squeezelite
sudo chown root:root /etc/init.d/squeezelite
sudo update-rc.d squeezelite defaults
sudo update-rc.d squeezelite enable

P.S. Please pay attention when you set the scheduler and the niceness; if you don’t know what are you doing remove “-N $NICENESS -P $SCHEDULER” from the script. If you have any question about this init script ask your questions in the comments below.

Automator (macOS)

Coming soon …

Batch script (Windows)

Coming soon …