Skip to content

Commit

Permalink
Merge pull request #25 from Ottercast/feature-shairport-pulseaudio
Browse files Browse the repository at this point in the history
Shairport-Sync using PulseAudio
  • Loading branch information
TobleMiner authored Apr 12, 2021
2 parents 1b6df62 + b0363cd commit dfff76b
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 5 deletions.
1 change: 1 addition & 0 deletions buildroot/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ source "$BR2_EXTERNAL_OTTERCASTAUDIO_PATH/package/ottercast_webinterface/Config.
source "$BR2_EXTERNAL_OTTERCASTAUDIO_PATH/package/shairport_sync_systemd_service/Config.in"
source "$BR2_EXTERNAL_OTTERCASTAUDIO_PATH/package/uhttpd_systemd_service/Config.in"
source "$BR2_EXTERNAL_OTTERCASTAUDIO_PATH/package/snapcast/Config.in"
source "$BR2_EXTERNAL_OTTERCASTAUDIO_PATH/package/shairport_sync_pulseaudio/Config.in"
9 changes: 5 additions & 4 deletions buildroot/configs/ottercast_s3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ BR2_PACKAGE_LUA_HTTP=y
BR2_PACKAGE_LUAJSON=y
BR2_PACKAGE_LUASOCKET=y
BR2_PACKAGE_WSAPI=y
BR2_PACKAGE_SPEEXDSP=y
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_DTC=y
Expand Down Expand Up @@ -70,10 +71,6 @@ BR2_PACKAGE_IPROUTE2=y
BR2_PACKAGE_IPTABLES=y
BR2_PACKAGE_IPUTILS=y
BR2_PACKAGE_IW=y
BR2_PACKAGE_SHAIRPORT_SYNC=y
BR2_PACKAGE_SHAIRPORT_SYNC_CONVOLUTION=y
BR2_PACKAGE_SHAIRPORT_SYNC_DBUS=y
BR2_PACKAGE_SHAIRPORT_SYNC_LIBSOXR=y
BR2_PACKAGE_UHTTPD=y
BR2_PACKAGE_WGET=y
BR2_PACKAGE_WPA_SUPPLICANT=y
Expand Down Expand Up @@ -117,3 +114,7 @@ BR2_PACKAGE_SHAIRPORT_SYNC_SYSTEMD_SERVICE=y
BR2_PACKAGE_UHTTPD_SYSTEMD_SERVICE=y
BR2_PACKAGE_SNAPCAST=y
BR2_PACKAGE_SNAPCAST_SERVER=y
BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO=y
BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_CONVOLUTION=y
BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_DBUS=y
BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_LIBSOXR=y
1 change: 1 addition & 0 deletions buildroot/package/ottercast_webinterface/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define OTTERCAST_WEBINTERFACE_INSTALL_TARGET_CMDS
mkdir -p $(TARGET_DIR)/etc/wpa_supplicant/
$(INSTALL) -D -m 0644 $(OTTERCAST_WEBINTERFACE_PKGDIR)/src/spotifyd $(TARGET_DIR)/etc/default/spotifyd
$(INSTALL) -D -m 0644 $(OTTERCAST_WEBINTERFACE_PKGDIR)/src/uhttpd $(TARGET_DIR)/etc/default/uhttpd
$(INSTALL) -D -m 0644 $(OTTERCAST_WEBINTERFACE_PKGDIR)/src/shairport-sync $(TARGET_DIR)/etc/default/shairport-sync

$(INSTALL) -D -m 0644 $(@D)/example_config.ini $(BINARIES_DIR)/config.ini
endef
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SHAIRPORT_SYNC_ARGS= -o pa
76 changes: 76 additions & 0 deletions buildroot/package/shairport_sync_pulseaudio/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
config BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO
bool "shairport_sync_pulseaudio"
depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL
depends on BR2_INSTALL_LIBSTDCPP
select BR2_PACKAGE_ALSA_LIB
select BR2_PACKAGE_ALSA_LIB_MIXER
select BR2_PACKAGE_LIBCONFIG
select BR2_PACKAGE_OPENSSL if !BR2_PACKAGE_MBEDTLS
select BR2_PACKAGE_POPT
help
Shairport Sync emulates an AirPort Express for the purpose
of streaming audio from iTunes, iPods, iPhones, iPads and
AppleTVs. Audio played by a Shairport Sync-powered device
stays in synchrony with the source and thus with other
devices that are playing the same source
synchronously. Thus, for example, synchronised multi-room
audio is possible without difficulty.

https://github.com/mikebrady/shairport-sync

if BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO

config BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_CONVOLUTION
bool "convolution support"
select BR2_PACKAGE_LIBSNDFILE
help
Enable audio DSP convolution support.

config BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_DBUS
bool "dbus support"
depends on BR2_USE_WCHAR # libglib2
depends on BR2_TOOLCHAIN_HAS_THREADS # libglib2
depends on BR2_USE_MMU # libglib2
select BR2_PACKAGE_LIBGLIB2
help
Enable support for support for the MPRIS and native
Shairport Sync D-Bus interface.

comment "shairport-sync dbus support needs a toolchain w/ wchar, threads"
depends on BR2_USE_MMU
depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS

config BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_LIBSOXR
bool "libsoxr support"
select BR2_PACKAGE_LIBSOXR
help
Enable support for libsoxr, the SoX Resampler library.

Briefly, Shairport Sync keeps in step with the audio source
by deleting or inserting frames of audio into the stream as
needed. This "interpolation" is normally inaudible, but it
can be heard in some circumstances. Libsoxr allows this
interpolation to be done much more smoothly and subtly.

config BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_MQTT
bool "mqtt support"
depends on BR2_USE_MMU # avahi
depends on BR2_TOOLCHAIN_HAS_THREADS # avahi
depends on !BR2_STATIC_LIBS # avahi
select BR2_PACKAGE_AVAHI
select BR2_PACKAGE_AVAHI_DAEMON
select BR2_PACKAGE_DBUS
select BR2_PACKAGE_MOSQUITTO
help
Enable support for the MQTT, the Message Queuing Telemetry
Transport protocol.

comment "shairport-sync mqtt support needs a toolchain w/ dynamic library, threads"
depends on BR2_USE_MMU
depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS

endif

comment "shairport-sync needs a toolchain w/ C++, NPTL"
depends on BR2_USE_MMU
depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS_NPTL
27 changes: 27 additions & 0 deletions buildroot/package/shairport_sync_pulseaudio/S99shairport-sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/sh

# Additional options that are passed to Shairport Sync
OPTIONS="-d"

case "$1" in
start)
printf "Starting shairport-sync: "
start-stop-daemon -S -q --exec /usr/bin/shairport-sync -- $OPTIONS
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
printf "Stopping shairport-sync: "
start-stop-daemon -K -q --exec /usr/bin/shairport-sync \
-p /var/run/shairport-sync/shairport-sync.pid
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Locally calculated
sha256 0aa08d7d295d241f1ca8cabdc52580fad2be84b32c6b55b316121933c9aac4b4 shairport_sync_pulseaudio-pulse-latency-2.tar.gz
sha256 7f8d4ecec53f2f681a962467bf09205568fc936c8c31a9ee07b1bd72d3d95b12 LICENSES
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
################################################################################
#
# shairport-sync
#
################################################################################

SHAIRPORT_SYNC_PULSEAUDIO_VERSION = pulse-latency-2
SHAIRPORT_SYNC_PULSEAUDIO_SITE = $(call github,manawyrm,shairport-sync,$(SHAIRPORT_SYNC_PULSEAUDIO_VERSION))

SHAIRPORT_SYNC_PULSEAUDIO_LICENSE = MIT, BSD-3-Clause
SHAIRPORT_SYNC_PULSEAUDIO_LICENSE_FILES = LICENSES
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES = alsa-lib libconfig popt host-pkgconf

# git clone, no configure
SHAIRPORT_SYNC_PULSEAUDIO_AUTORECONF = YES

SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS = --with-alsa \
--with-pa \
--with-metadata \
--with-pipe \
--with-stdout

SHAIRPORT_SYNC_PULSEAUDIO_CONF_ENV += LIBS="$(SHAIRPORT_SYNC_PULSEAUDIO_CONF_LIBS)"

# Avahi or tinysvcmdns (shaiport-sync bundles its own version of tinysvcmdns).
# Avahi support needs libavahi-client, which is built by avahi if avahi-daemon
# and dbus is selected. Since there is no BR2_PACKAGE_LIBAVAHI_CLIENT config
# option yet, use the avahi-daemon and dbus congig symbols to check for
# libavahi-client.
ifeq ($(BR2_PACKAGE_AVAHI_DAEMON)$(BR2_PACKAGE_DBUS),yy)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += avahi
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-avahi
else
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-tinysvcmdns
endif

ifeq ($(BR2_PACKAGE_LIBDAEMON),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += libdaemon
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-libdaemon
endif

# OpenSSL or mbedTLS
ifeq ($(BR2_PACKAGE_OPENSSL),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += openssl
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-ssl=openssl
else
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += mbedtls
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-ssl=mbedtls
SHAIRPORT_SYNC_PULSEAUDIO_CONF_LIBS += -lmbedx509 -lmbedcrypto
ifeq ($(BR2_PACKAGE_MBEDTLS_COMPRESSION),y)
SHAIRPORT_SYNC_PULSEAUDIO_CONF_LIBS += -lz
endif
endif

ifeq ($(BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_CONVOLUTION),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += libsndfile
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-convolution
endif

ifeq ($(BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_DBUS),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += libglib2
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-dbus-interface --with-mpris-interface
endif

ifeq ($(BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_LIBSOXR),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += libsoxr
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-soxr
endif

ifeq ($(BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO_MQTT),y)
SHAIRPORT_SYNC_PULSEAUDIO_DEPENDENCIES += avahi dbus mosquitto
SHAIRPORT_SYNC_PULSEAUDIO_CONF_OPTS += --with-mqtt-client
endif

define SHAIRPORT_SYNC_PULSEAUDIO_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/shairport-sync \
$(TARGET_DIR)/usr/bin/shairport-sync
$(INSTALL) -D -m 0644 $(@D)/scripts/shairport-sync.conf \
$(TARGET_DIR)/etc/shairport-sync.conf
endef

define SHAIRPORT_SYNC_PULSEAUDIO_INSTALL_INIT_SYSV
$(INSTALL) -D -m 0755 package/shairport-sync/S99shairport-sync \
$(TARGET_DIR)/etc/init.d/S99shairport-sync
endef

$(eval $(autotools-package))
2 changes: 1 addition & 1 deletion buildroot/package/shairport_sync_systemd_service/Config.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config BR2_PACKAGE_SHAIRPORT_SYNC_SYSTEMD_SERVICE
bool "Systemd unit file for shairport-sync"
depends on BR2_PACKAGE_SHAIRPORT_SYNC
depends on BR2_PACKAGE_SHAIRPORT_SYNC_PULSEAUDIO
depends on BR2_PACKAGE_SYSTEMD
help
Provides a systemd unit file for shairport-sync

0 comments on commit dfff76b

Please sign in to comment.