From 97bb0da717a0ce9634f7981557a3c1fbd4ef3c2e Mon Sep 17 00:00:00 2001 From: Timo Gurr Date: Sat, 7 Jan 2017 03:31:57 +0100 Subject: [PATCH 1/9] librespot upstream changed the backend name from stdout to pipe The stdout backend has been merged, but also been renamed in a later commit: https://github.com/plietar/librespot/commit/9c3541c41b9f706153a696774be4eb7f8867fcd6 --- server/streamreader/spotifyStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/streamreader/spotifyStream.cpp b/server/streamreader/spotifyStream.cpp index 3c45150e..820128cc 100644 --- a/server/streamreader/spotifyStream.cpp +++ b/server/streamreader/spotifyStream.cpp @@ -42,7 +42,7 @@ SpotifyStream::SpotifyStream(PcmListener* pcmListener, const StreamUri& uri) : P if (password.empty()) throw SnapException("missing parameter \"password\""); - params_ = "--name \"" + devicename + "\" --username \"" + username + "\" --password \"" + password + "\" --bitrate " + bitrate + " --backend stdout"; + params_ = "--name \"" + devicename + "\" --username \"" + username + "\" --password \"" + password + "\" --bitrate " + bitrate + " --backend pipe"; // logO << "params: " << params << "\n"; } From 8500c8f81c0bdb7eff5d9847fc2825b873f28fcf Mon Sep 17 00:00:00 2001 From: realglotzi Date: Sun, 8 Jan 2017 18:46:51 +0100 Subject: [PATCH 2/9] snapclient.service/snapserver.service: Snapcast has to wait until complete network stack is up, in particular systemd-timesyncd is up and time is set. If not, there are drop outs after boot on the client. This fixes https://github.com/badaix/snapcast/issues/138. Signed-off-by: realglotzi --- client/debian/snapclient.service | 4 +++- server/debian/snapserver.service | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/debian/snapclient.service b/client/debian/snapclient.service index 210e1646..bdeb35a3 100644 --- a/client/debian/snapclient.service +++ b/client/debian/snapclient.service @@ -1,12 +1,14 @@ [Unit] Description=Snapcast client -After=network.target +After=network-online.target sound.target +Requires=network-online.target [Service] EnvironmentFile=-/etc/default/snapclient Type=forking ExecStart=/usr/sbin/snapclient $SNAPCLIENT_OPTS PIDFile=/var/run/snapclient.pid +Restart=always [Install] WantedBy=multi-user.target diff --git a/server/debian/snapserver.service b/server/debian/snapserver.service index 1129bae6..758abb36 100644 --- a/server/debian/snapserver.service +++ b/server/debian/snapserver.service @@ -1,12 +1,14 @@ [Unit] Description=Snapcast server -After=network.target +After=network-online.target sound.target +Requires=network-online.target [Service] EnvironmentFile=-/etc/default/snapserver Type=forking ExecStart=/usr/sbin/snapserver $SNAPSERVER_OPTS PIDFile=/var/run/snapserver.pid +Restart=always [Install] WantedBy=multi-user.target From 2cc2574eeba84a32f449a3c367b8e55ea8dc4f9a Mon Sep 17 00:00:00 2001 From: unimatrix27 Date: Mon, 9 Jan 2017 15:28:49 +0100 Subject: [PATCH 3/9] Update Makefile --- server/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/Makefile b/server/Makefile index cfa2d45f..77b60999 100644 --- a/server/Makefile +++ b/server/Makefile @@ -117,7 +117,7 @@ endif installsystemd: @echo using systemd; \ cp debian/$(BIN).service /lib/systemd/system/$(BIN).service; \ - cp debian/$(BIN).default /etc/default/$(BIN); \ + cp -n debian/$(BIN).default /etc/default/$(BIN); \ systemctl daemon-reload; \ systemctl enable $(BIN); \ systemctl start $(BIN); \ @@ -125,7 +125,7 @@ installsystemd: installsysv: @echo using sysv; \ cp debian/$(BIN).init /etc/init.d/$(BIN); \ - cp debian/$(BIN).default /etc/default/$(BIN); \ + cp -n debian/$(BIN).default /etc/default/$(BIN); \ update-rc.d $(BIN) defaults; \ /etc/init.d/$(BIN) start; \ From 4818b7826c85373345640c5c24cbd204a9de85f4 Mon Sep 17 00:00:00 2001 From: unimatrix27 Date: Mon, 9 Jan 2017 15:30:09 +0100 Subject: [PATCH 4/9] Update Makefile --- client/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/Makefile b/client/Makefile index f62c9ace..4f9fc844 100644 --- a/client/Makefile +++ b/client/Makefile @@ -111,7 +111,7 @@ endif installsystemd: @echo using systemd; \ cp debian/$(BIN).service /lib/systemd/system/$(BIN).service; \ - cp debian/$(BIN).default /etc/default/$(BIN); \ + cp -n debian/$(BIN).default /etc/default/$(BIN); \ systemctl daemon-reload; \ systemctl enable $(BIN); \ systemctl start $(BIN); \ @@ -119,7 +119,7 @@ installsystemd: installsysv: @echo using sysv; \ cp debian/$(BIN).init /etc/init.d/$(BIN); \ - cp debian/$(BIN).default /etc/default/$(BIN); \ + cp -n debian/$(BIN).default /etc/default/$(BIN); \ update-rc.d $(BIN) defaults; \ /etc/init.d/$(BIN) start; \ From 4774d826ddff8a8bde9db4505e71bdb7fc3861d9 Mon Sep 17 00:00:00 2001 From: realglotzi Date: Wed, 11 Jan 2017 10:49:03 +0100 Subject: [PATCH 5/9] Removed sound.target from snapserver.service because the server does not use the sound device Signed-off-by: realglotzi --- server/debian/snapserver.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/debian/snapserver.service b/server/debian/snapserver.service index 758abb36..312b3c8f 100644 --- a/server/debian/snapserver.service +++ b/server/debian/snapserver.service @@ -1,6 +1,6 @@ [Unit] Description=Snapcast server -After=network-online.target sound.target +After=network-online.target Requires=network-online.target [Service] From e1b617ae39fb52798ca843f74d4cf8f855fc35fd Mon Sep 17 00:00:00 2001 From: unimatrix27 Date: Thu, 12 Jan 2017 18:11:00 +0100 Subject: [PATCH 6/9] Mention new FHEM module in Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c4bbc966..1e86171c 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ There is also an unofficial WebApp from @atoomic [atoomic/snapcast-volume-ui](ht This app list all clients connected to a server and allow to control individualy the volume of each client. Once installed, you can use any mobile device, laptop, desktop, or browser. +There is also an [unofficial FHEM module](https://forum.fhem.de/index.php/topic,62389.0.html) from @unimatrix27 which integrates a snapcast controller in the the [FHEM](https://fhem.de/fhem.html) home automation system + Setup of audio players/server ----------------------------- Snapcast can be used with a number of different audio players and servers, and so it can be integrated into your favorite audio-player solution and make it synced-multiroom capable. From af73c6996074f7483c7ad817a410b253ba151577 Mon Sep 17 00:00:00 2001 From: Nick Knudson Date: Sun, 15 Jan 2017 15:05:19 -0800 Subject: [PATCH 7/9] added client compilation support for TARGET=BUILDROOT --- README.md | 1 + buildroot/Config.in | 1 + buildroot/external.desc | 1 + buildroot/external.mk | 1 + buildroot/package/snapcast/Config.in | 4 +++ buildroot/package/snapcast/S99snapclient | 35 ++++++++++++++++++++++++ buildroot/package/snapcast/snapcast.mk | 32 ++++++++++++++++++++++ client/Makefile | 6 ++++ doc/build.md | 31 +++++++++++++++++++++ 9 files changed, 112 insertions(+) create mode 100644 buildroot/Config.in create mode 100644 buildroot/external.desc create mode 100644 buildroot/external.mk create mode 100644 buildroot/package/snapcast/Config.in create mode 100644 buildroot/package/snapcast/S99snapclient create mode 100644 buildroot/package/snapcast/snapcast.mk diff --git a/README.md b/README.md index c4bbc966..90dc86b4 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Please follow this [guide](doc/build.md) to build Snapcast for * [macOS](doc/build.md#macos-native) * [Android](doc/build.md#android-cross-compile) * [OpenWrt](doc/build.md#openwrt-cross-compile) +* [Buildroot](doc/build.md#buildroot-cross-compile) ###Install debian packages Download the debian package for your CPU architecture from the [latest release page](https://github.com/badaix/snapcast/releases/latest), e.g. for Raspberry pi `snapclient_0.x.x_armhf.deb` diff --git a/buildroot/Config.in b/buildroot/Config.in new file mode 100644 index 00000000..61d9d1b9 --- /dev/null +++ b/buildroot/Config.in @@ -0,0 +1 @@ +source "$BR2_EXTERNAL_SNAPCAST_PATH/package/snapcast/Config.in" diff --git a/buildroot/external.desc b/buildroot/external.desc new file mode 100644 index 00000000..ac3dd844 --- /dev/null +++ b/buildroot/external.desc @@ -0,0 +1 @@ +name: SNAPCAST diff --git a/buildroot/external.mk b/buildroot/external.mk new file mode 100644 index 00000000..433f339f --- /dev/null +++ b/buildroot/external.mk @@ -0,0 +1 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_SNAPCAST_PATH)/package/*/*.mk)) diff --git a/buildroot/package/snapcast/Config.in b/buildroot/package/snapcast/Config.in new file mode 100644 index 00000000..f9201e0a --- /dev/null +++ b/buildroot/package/snapcast/Config.in @@ -0,0 +1,4 @@ +config BR2_PACKAGE_SNAPCAST + bool "snapcast" + help + Synchronous multi-room audio player diff --git a/buildroot/package/snapcast/S99snapclient b/buildroot/package/snapcast/S99snapclient new file mode 100644 index 00000000..e7c77a8b --- /dev/null +++ b/buildroot/package/snapcast/S99snapclient @@ -0,0 +1,35 @@ +#! /bin/sh + +start() { + echo -n "Starting snapclient: " + start-stop-daemon -S -q -b -x snapclient + [ $? = 0 ] && echo "OK" || echo "FAIL" +} + +stop() { + echo -n "Stopping snapclient: " + start-stop-daemon -K -q -x snapclient + [ $? = 0 ] && echo "OK" || echo "FAIL" +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/buildroot/package/snapcast/snapcast.mk b/buildroot/package/snapcast/snapcast.mk new file mode 100644 index 00000000..617ad218 --- /dev/null +++ b/buildroot/package/snapcast/snapcast.mk @@ -0,0 +1,32 @@ +################################################################################ +# +# snapcast +# +################################################################################ + +SNAPCAST_VERSION = master +SNAPCAST_SITE = https://github.com/badaix/snapcast +SNAPCAST_SITE_METHOD = git +SNAPCAST_DEPENDENCIES = libogg alsa-lib # libstdcpp libavahi-client libatomic libflac libvorbisidec +SNAPCAST_LICENSE = GPLv3 +SNAPCAST_LICENSE_FILES = COPYING + +# http://lists.busybox.net/pipermail/buildroot/2013-March/069811.html +define SNAPCAST_EXTRACT_CMDS + rm -rf $(@D) + (git clone --depth 1 $(SNAPCAST_SITE) $(@D) && \ + cd $(@D)/externals && \ + git submodule update --init --recursive) + touch $(@D)/.stamp_downloaded +endef + +define SNAPCAST_BUILD_CMDS + $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D)/client TARGET=BUILDROOT +endef + +define SNAPCAST_INSTALL_TARGET_CMDS + $(INSTALL) -m 0755 -D $(@D)/client/snapclient $(TARGET_DIR)/usr/sbin/snapclient + $(INSTALL) -m 0755 -D $(SNAPCAST_PKGDIR)/S99snapclient $(TARGET_DIR)/etc/init.d/S99snapclient +endef + +$(eval $(generic-package)) diff --git a/client/Makefile b/client/Makefile index 4f9fc844..bc23fa1e 100644 --- a/client/Makefile +++ b/client/Makefile @@ -36,6 +36,12 @@ CXXFLAGS += -pthread -DNO_CPP11_STRING -DHAS_TREMOR -DHAS_ALSA -DHAS_AVAHI -DHAS LDFLAGS = -lasound -lvorbisidec -logg -lFLAC -lavahi-client -lavahi-common -latomic OBJ += player/alsaPlayer.o browseZeroConf/browseAvahi.o +else ifeq ($(TARGET), BUILDROOT) + +CXXFLAGS += -pthread -DNO_CPP11_STRING -DHAS_TREMOR -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON +LDFLAGS += -lasound -lvorbisidec -logg -lFLAC -lavahi-client -lavahi-common -latomic +OBJ += player/alsaPlayer.o browseZeroConf/browseAvahi.o + else ifeq ($(TARGET), MACOS) CXX = /usr/bin/g++ diff --git a/doc/build.md b/doc/build.md index 18d3e477..b1694996 100644 --- a/doc/build.md +++ b/doc/build.md @@ -200,3 +200,34 @@ Build Snapcast: $ make package/sxx/snapcast/compile The packaged `ipk` files are in `/bin/ar71xx/packages/base/snap[client|server]_x.x.x_ar71xx.ipk` + +##Buildroot (Cross compile) +This example will show you how to add snapcast to [Buildroot](https://buildroot.org/). + +###Buildroot setup +Buildroot recommends [keeping customizations outside of the main Buildroot directory](https://buildroot.org/downloads/manual/manual.html#outside-br-custom) which is what this example will walk through. + +Clone Buildroot to some place in your home directory (``): + + $ git clone --branch BUILDROOT_VERSION --depth=1 git://git.buildroot.net/buildroot + +The `/buildroot` is currently setup as an external Buildroot folder following the [recommended structure](https://buildroot.org/downloads/manual/manual.html#customize-dir-structure). As of [Buildroot 2016.11](https://git.buildroot.net/buildroot/tag/?h=2016.11) you may specify multiple BR2_EXTERNAL trees. If you are using a version of Buildroot prior to this, then you will need to manually merge `/buildroot` with your existing Buildroot external tree. + +Now add the following packages to your Buildroot `.config` file: + + BR2_PACKAGE_FLAC=y + BR2_PACKAGE_LIBOGG=y + BR2_PACKAGE_TREMOR=y + BR2_PACKAGE_SNAPCAST=y + +Or use `menuconfig` to add them graphically: + + $ cd && make BR2_EXTERNAL=/buildroot menuconfig + +Or if you have another Buildroot external tree (``): + + $ cd && make BR2_EXTERNAL=/buildroot: menuconfig + +And finally run the build: + + $ cd && make BR2_EXTERNAL=/buildroot: From 761b74edb22092f5378f58b85e919b3fb257c466 Mon Sep 17 00:00:00 2001 From: happyleaves Date: Mon, 16 Jan 2017 10:35:30 -0500 Subject: [PATCH 8/9] mention HASS component --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e86171c..a5959d66 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,9 @@ There is also an unofficial WebApp from @atoomic [atoomic/snapcast-volume-ui](ht This app list all clients connected to a server and allow to control individualy the volume of each client. Once installed, you can use any mobile device, laptop, desktop, or browser. -There is also an [unofficial FHEM module](https://forum.fhem.de/index.php/topic,62389.0.html) from @unimatrix27 which integrates a snapcast controller in the the [FHEM](https://fhem.de/fhem.html) home automation system +There is also an [unofficial FHEM module](https://forum.fhem.de/index.php/topic,62389.0.html) from @unimatrix27 which integrates a snapcast controller in to the [FHEM](https://fhem.de/fhem.html) home automation system. + +There is a [snapcast component for Home Assistant](https://home-assistant.io/components/media_player.snapcast/) which integrates a snapcast controller in to the [Home Assistant](https://home-assistant.io/) home automation system. Setup of audio players/server ----------------------------- From d3d5a01f373ac3f218307f086cdb296aca8f672c Mon Sep 17 00:00:00 2001 From: Nick Knudson Date: Sat, 4 Feb 2017 01:30:25 -0800 Subject: [PATCH 9/9] cleaned up buildroot instructions, added raspberry pi instructions, added snapcast_defconfig --- README.md | 1 + buildroot/configs/snapcast_defconfig | 40 ++++++++++++++++++++++++++++ doc/build.md | 23 ++++++++-------- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 buildroot/configs/snapcast_defconfig diff --git a/README.md b/README.md index 8f7a2369..f3a3e95b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Please follow this [guide](doc/build.md) to build Snapcast for * [Android](doc/build.md#android-cross-compile) * [OpenWrt](doc/build.md#openwrt-cross-compile) * [Buildroot](doc/build.md#buildroot-cross-compile) + * [Raspberry Pi](doc/build.md#raspberry-pi-cross-compile) ###Install debian packages Download the debian package for your CPU architecture from the [latest release page](https://github.com/badaix/snapcast/releases/latest), e.g. for Raspberry pi `snapclient_0.x.x_armhf.deb` diff --git a/buildroot/configs/snapcast_defconfig b/buildroot/configs/snapcast_defconfig new file mode 100644 index 00000000..cc91640b --- /dev/null +++ b/buildroot/configs/snapcast_defconfig @@ -0,0 +1,40 @@ +# Snapcast Packages +BR2_GCC_VERSION_4_9_X=y +BR2_GCC_VERSION="4.9.4" +BR2_TOOLCHAIN_GCC_AT_LEAST="4.9" +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_PACKAGE_DBUS=y +BR2_PACKAGE_EXPAT=y +BR2_PACKAGE_LIBDAEMON=y +BR2_PACKAGE_AVAHI=y +BR2_PACKAGE_AVAHI_AUTOIPD=y +BR2_PACKAGE_AVAHI_DAEMON=y +BR2_PACKAGE_AVAHI_LIBDNSSD_COMPATIBILITY=y +BR2_PACKAGE_ALSA_LIB=y +BR2_PACKAGE_ALSA_LIB_DEVDIR="/dev/snd" +BR2_PACKAGE_ALSA_LIB_PCM_PLUGINS="all" +BR2_PACKAGE_ALSA_LIB_CTL_PLUGINS="all" +BR2_PACKAGE_ALSA_LIB_ALOAD=y +BR2_PACKAGE_ALSA_LIB_MIXER=y +BR2_PACKAGE_ALSA_LIB_PCM=y +BR2_PACKAGE_ALSA_LIB_RAWMIDI=y +BR2_PACKAGE_ALSA_LIB_HWDEP=y +BR2_PACKAGE_ALSA_LIB_SEQ=y +BR2_PACKAGE_ALSA_LIB_ALISP=y +BR2_PACKAGE_ALSA_LIB_OLD_SYMBOLS=y +BR2_PACKAGE_ALSA_UTILS=y +BR2_PACKAGE_ALSA_UTILS_ALSACONF=y +BR2_PACKAGE_ALSA_UTILS_ALSACTL=y +BR2_PACKAGE_ALSA_UTILS_AMIXER=y +BR2_PACKAGE_ALSA_UTILS_APLAY=y +BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y +BR2_PACKAGE_LIBCURL=y +BR2_PACKAGE_LIBAO=y +BR2_PACKAGE_LIBVORBIS=y +BR2_PACKAGE_VORBIS_TOOLS=y +BR2_PACKAGE_FLAC=y +BR2_PACKAGE_LIBOGG=y +BR2_PACKAGE_TREMOR=y +BR2_PACKAGE_SNAPCAST=y + +# Other Packages diff --git a/doc/build.md b/doc/build.md index b1694996..ba9d1cbe 100644 --- a/doc/build.md +++ b/doc/build.md @@ -209,25 +209,24 @@ Buildroot recommends [keeping customizations outside of the main Buildroot direc Clone Buildroot to some place in your home directory (``): - $ git clone --branch BUILDROOT_VERSION --depth=1 git://git.buildroot.net/buildroot + $ BUILDROOT_VERSION=2016.11.2 + $ git clone --branch $BUILDROOT_VERSION --depth=1 git://git.buildroot.net/buildroot The `/buildroot` is currently setup as an external Buildroot folder following the [recommended structure](https://buildroot.org/downloads/manual/manual.html#customize-dir-structure). As of [Buildroot 2016.11](https://git.buildroot.net/buildroot/tag/?h=2016.11) you may specify multiple BR2_EXTERNAL trees. If you are using a version of Buildroot prior to this, then you will need to manually merge `/buildroot` with your existing Buildroot external tree. -Now add the following packages to your Buildroot `.config` file: +Now configure buildroot with the [required packages](/buildroot/configs/snapcast_defconfig) (you can also manually add them to your project's existing defconfig): - BR2_PACKAGE_FLAC=y - BR2_PACKAGE_LIBOGG=y - BR2_PACKAGE_TREMOR=y - BR2_PACKAGE_SNAPCAST=y + $ cd && make BR2_EXTERNAL=/buildroot snapcast_defconfig -Or use `menuconfig` to add them graphically: +Then use `menuconfig` to configure the rest of your project: $ cd && make BR2_EXTERNAL=/buildroot menuconfig -Or if you have another Buildroot external tree (``): - - $ cd && make BR2_EXTERNAL=/buildroot: menuconfig - And finally run the build: - $ cd && make BR2_EXTERNAL=/buildroot: + $ cd && make BR2_EXTERNAL=/buildroot + +##Raspberry Pi (Cross compile) +This example will show you how to add snapcast to [Buildroot](https://buildroot.org/) and compile for Raspberry Pi. + +* https://github.com/nickaknudson/snapcast-pi