Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stretch fix #105

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Super Simple Raspberry Pi Audio Receiver Install.

**\*Requires Raspbian Jessie LITE** you can find the lastest Jessie Lite Image [here](http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/)\*
**\*Requires Raspbian Jessie or Raspbian Stretch LITE** you can find the lastest Jessie Lite Image [here](http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/)\* and the latest Stretch lite image [here](https://www.raspberrypi.org/downloads/raspbian/)\*
![SSPARI](https://github.com/BaReinhard/Super-Simple-Raspberry-Pi-Audio-Receiver-Install/blob/master/img/SSRPARI_1080_668.png?raw=true)

## SSPARI v2.0

**_Now Live, includes the following new features:_**

* Raspbian Stretch Support!
* Volumio Compatibility for Bluetooth Only - Installs A2DP Bluetooth Streaming to RPI
* Backing up of original files
* Uninstallation functionality
Expand Down
59 changes: 44 additions & 15 deletions bt_pa_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ then
source functions.sh
source dependencies.sh
fi
if [ -z "$VERSION" ]
then
VERSION=`cat /etc/os-release | grep VERSION= | sed "s/VERSION=//"`
export VERSION
fi



exc sudo cp usr/local/bin/volume-watcher.py /usr/local/bin/volume-watcher.py
exc sudo chmod +x /usr/local/bin/volume-watcher.py
exc sudo cp lib/systemd/system/volume-watcher.service /lib/systemd/system/volume-watcher.service
exc sudo systemctl enable volume-watcher
exc sudo cp lib/systemd/system/systemd-udevd.service /lib/systemd/system/systemd-udevd.service
exc sudo systemctl daemon-reload
exc cd `dirname $0`

sudo echo "PRETTY_HOSTNAME=$BluetoothName" >> /tmp/machine-info
Expand All @@ -53,7 +61,13 @@ fi
exc sudo chmod +x /etc/init.d/bluetooth-agent
exc sudo update-rc.d bluetooth-agent defaults

exc sudo cp usr/local/bin/bluez-udev /usr/local/bin
if [ "$VERSION" = "\"8 (jessie)\"" ]
then
exc sudo cp usr/local/bin/bluez-udev /usr/local/bin
elif [ "$VERSION" = "\"9 (stretch)\"" ]
then
exc sudo cp usr/local/bin/bluez-udev.stretch /usr/local/bin/bluez-udev
fi
exc sudo chmod 755 /usr/local/bin/bluez-udev

exc sudo cp usr/local/bin/simple-agent.autotrust /usr/local/bin
Expand Down Expand Up @@ -167,13 +181,6 @@ EOT
#sudo service bluetooth-agent start &
# BT FIX

exc remove_dir /etc/pulsebackup
exc sudo mkdir /etc/pulsebackup
exc sudo cp /etc/pulse/* /etc/pulsebackup/

exc cd ~
exc remove_dir pulseaudio
exc git clone --branch v6.0 https://github.com/pulseaudio/pulseaudio

exc cd ~
exc remove_dir json-c
Expand All @@ -185,16 +192,38 @@ exc make
exc sudo make install
exc cd ~
exc remove_dir libsndfile
exc git clone git://github.com/erikd/libsndfile.git
exc git clone https://github.com/erikd/libsndfile.git
exc cd libsndfile
exc ./autogen.sh
exc ./configure --enable-werror
exc make
exc sudo make install
exc cd ~
exc cd pulseaudio
exc sudo ./bootstrap.sh
exc sudo make
exc sudo make install
exc sudo ldconfig
exc sudo cp /etc/pulsebackup/* /etc/pulse

if [ "$VERSION" = "\"8 (jessie)\"" ]
then
log "Raspbian Jessie Found"
log "Pulseaudio Version Below v6.0, upgrading from source"
exc remove_dir /etc/pulsebackup
exc sudo mkdir /etc/pulsebackup
exc sudo cp /etc/pulse/* /etc/pulsebackup/
exc cd ~
exc remove_dir pulseaudio
exc git clone --branch v6.0 https://github.com/pulseaudio/pulseaudio
exc cd pulseaudio
exc sudo ./bootstrap.sh
exc sudo make
exc sudo make install
exc sudo ldconfig
exc sudo cp /etc/pulsebackup/* /etc/pulse
elif [ "$VERSION" = "\"9 (stretch)\"" ]
then
log "Raspbian Stretch Found"
log "Pulseaudio Version Already Exceeds v6.0"
log "Patching System Daemon"
exc sudo sed -i "s+DAEMON=/usr/local/bin/pulseaudio+DAEMON=/usr/bin/pulseaudio+" /etc/init.d/pulseaudio
exc sudo systemctl daemon-reload
else
log "You are running an unsupported VERSION of RASPBIAN"
fi

16 changes: 16 additions & 0 deletions bt_pa_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@ then
fi


VERSION=`cat /etc/os-release | grep VERSION= | sed "s/VERSION=//"`


if [ "$VERSION" = "\"8 (jessie)\"" ]
then
log "Raspbian Jessie Found"
for _dep in ${JESSIE_BT_DEPS[@]}; do
apt_install $_dep;
done
elif [ "$VERSION" = "\"9 (stretch)\"" ]
then
log "Raspbian Stretch Found"
for _dep in ${STRETCH_BT_DEPS[@]}; do
apt_install $_dep;
done
else
log "You are running an unsupported VERSION of RASPBIAN"
fi
for _dep in ${BT_DEPS[@]}; do
apt_install $_dep;
done
Expand Down
6 changes: 5 additions & 1 deletion dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

BT_DEPS="pulseaudio-module-bluetooth python-dbus libltdl-dev pulseaudio libtool intltool libsndfile-dev libcap-dev libjson0-dev libasound2-dev libavahi-client-dev libbluetooth-dev libglib2.0-dev libsamplerate0-dev libsbc-dev libspeexdsp-dev libssl-dev libtdb-dev libbluetooth-dev intltool autoconf autogen automake build-essential libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev pkg-config python"
BT_DEPS="pulseaudio-module-bluetooth python-dbus libltdl-dev pulseaudio libtool intltool libsndfile-dev libcap-dev libasound2-dev libavahi-client-dev libbluetooth-dev libglib2.0-dev libsamplerate0-dev libsbc-dev libspeexdsp-dev libssl-dev libtdb-dev libbluetooth-dev intltool autoconf autogen automake build-essential libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev pkg-config python"

JESSIE_BT_DEPS="libjson0-dev"

STRETCH_BT_DEPS="libjson-c-dev autopoint"

VOLUMIO_DEPS="bluez bluez-firmware libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libltdl-dev libsamplerate0-dev libsndfile1-dev libasound2-dev libavahi-client-dev libspeexdsp-dev liborc-0.4-dev intltool libtdb-dev libssl-dev libjson0-dev libsbc-dev libcap-dev"

Expand Down
26 changes: 14 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ do
# Car Installation - Previously Raspberry Pi Audio Receiver Install Car Install
AirPlay="y"
Bluetooth="y"
AP="y"
Kodi="y"
Lirc="y"
AP="n"
Kodi="n"
Lirc="n"
SoundCardInstall="y"
GMedia="n"
SNAPCAST="n"
Expand All @@ -67,15 +67,17 @@ do
AirPlay="y"
Bluetooth="y"
AP="n"
Kodi="y"
Lirc="y"
Kodi="n"
Lirc="n"
SoundCardInstall="y"
GMedia="y"
GMedia="n"
SNAPCAST="n"
break
;;
3)
# Access Point Install - Previously Network Without Internet
log "AP is not supported yet"
exit
AirPlay="n"
Bluetooth="n"
AP="y"
Expand Down Expand Up @@ -121,18 +123,18 @@ do
# Prompts the User to use the Raspberry Pi as an Access Point to create a network
# (needed for AirPlay when no existing network exists)
AP="n"
YesNo "Do you want to setup as an Access Point? (Necessary for AirPlay, in location without a Wireless Network) (y/n) : " && AP="y"
#YesNo "Do you want to setup as an Access Point? (Necessary for AirPlay, in location without a Wireless Network) (y/n) : " && AP="y"
# Prompts the User to use Kodi as a GUI for a Media Center
Kodi="n"
YesNo "Do you want Kodi installed? (y/n) : " && Kodi="y"
#YesNo "Do you want Kodi installed? (y/n) : " && Kodi="y"
# Prompts the User to use Lirc for Infrared Remote Support
# (matricom IR remote already setup for use with Kodi)
Lirc="n"
YesNo "Do you want to use infrared remotes? (y/n) : " && Lirc="y"
#YesNo "Do you want to use infrared remotes? (y/n) : " && Lirc="y"
SoundCardInstall="n"
YesNo "Do you want to use a Sound Card? (y/n) : " && SoundCardInstall="y"
GMedia="n"
YesNo "Do you want to setup device as a UPnP Renderer? (y/n) : " && GMedia="y"
#YesNo "Do you want to setup device as a UPnP Renderer? (y/n) : " && GMedia="y"
break
;;
*)
Expand Down Expand Up @@ -262,9 +264,9 @@ chmod +x ./*.sh
# Updates and Upgrades the Raspberry Pi

log "Updating via Apt-Get"
apt-get update -y &> /dev/null
apt-get update -y
log "Upgrading via Apt-Get"
apt-get upgrade -y &> /dev/null
apt-get upgrade -y


# If Bluetooth is Chosen, it installs Bluetooth Dependencies and issues commands for proper configuration
Expand Down
30 changes: 30 additions & 0 deletions lib/systemd/system/systemd-udevd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=udev Kernel Device Manager
Documentation=man:systemd-udevd.service(8) man:udev(7)
DefaultDependencies=no
Wants=systemd-udevd-control.socket systemd-udevd-kernel.socket
After=systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-sysusers.service
Before=sysinit.target
ConditionPathIsReadWrite=/sys

[Service]
Type=notify
OOMScoreAdjust=-1000
Sockets=systemd-udevd-control.socket systemd-udevd-kernel.socket
Restart=always
RestartSec=0
ExecStart=/lib/systemd/systemd-udevd
#KillMode=mixed
#WatchdogSec=3min
#TasksMax=infinity
#MountFlags=slave
#MemoryDenyWriteExecute=yes
#RestrictRealtime=yes
#RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6
2 changes: 0 additions & 2 deletions sound_card_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ save_original /etc/asound.conf
sudo cat << EOT >> /etc/asound.conf
pcm.pulse {
type pulse
card 0
}
ctl.pulse {
type pulse
card 0
}

pcm.!default {
Expand Down
Binary file added ssrpari_bluetooth.zip
Binary file not shown.
61 changes: 61 additions & 0 deletions usr/local/bin/bluez-udev.stretch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
audio_sink=0
name=$(sed 's/\"//g' <<< $NAME)
#exit if not a BT address
if [[ ! $name =~ ^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$ ]]; then exit 0; fi

bt_name=`grep Name /var/lib/bluetooth/*/$name/info | awk -F'=' '{print $2}'`
#sudo pkill arecord # Uncomment for Audio Line Input
audio_source=bluez_source.$(sed 's/:/_/g' <<< $name)
audio_source="$audio_source.a2dp_source"
action=$(expr "$ACTION" : "\([a-zA-Z]\+\).*")
logger "Action: $action"
if [ "$action" = "add" ]; then
logger "[$(basename $0)] Bluetooth device is being added [$name] - $bt_name"
logger "[$(basename $0)] Patching $audio_source into ALSA sink #$audio_sink"
#hciconfig hci0 noscan
bluetoothctl << EOT
discoverable off
EOT
amixer cset numid=3 1
amixer cset numid=3 50%
#espeak -s 160 -k 1 "Device, $bt_name Connected"
/usr/local/bin/say.sh "Device, $bt_name Connected"
amixer cset numid=3 90%
sleep 1
pactl set-sink-volume 0 65537
pactl set-source-volume $audio_source 90%



# loop back this source to the default sink
sleep 2s
handle=$(pactl load-module module-loopback source=$audio_source sink=$audio_sink)
logger "[$(basename $0)] PulseAudio module-loopback returned handle [$handle]"
logger "$bt_name"


fi

if [ "$action" = "remove" ]; then
logger "[$(basename $0)] Bluetooth device is being removed [$name] - $bt_name"
#hciconfig hci0 pscan

bluetoothctl << EOT
discoverable on
EOT

# remove any loopback modules assigned to this source
# only required for USB sound cards, which PulseAudio will not automatically remove
for handle in $(pactl list short modules | grep module-loopback | grep source=$audio_source | cut -f 1); do
logger "[$(basename $0)] Unloading module-loopback with handle [$handle]"
pactl unload-module $handle
done

#arecord -D plughw:1 -f dat | aplay -D plughw:1 -f dat& # Uncomment for Audio Line Input
sleep 5
amixer cset numid=3 80%
#espeak -s 160 -k 1 "Device, $bt_name Disconnected"
/usr/local/bin/say.sh "Device, $bt_name Disconnected"
amixer cset numid=3 80%
fi