From b871c31cda733bb3428275161e13308b22588249 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:47:24 +0100 Subject: [PATCH 01/16] Update CAR INSTALL.md --- CAR INSTALL.md | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 7dd87966..638c146a 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -1,5 +1,5 @@ -# Shairport Sync for Cars [Needs updating for Airplay 2] -If your car audio has an AUX input, you can get AirPlay in your car using Shairport Sync. Together, Shairport Sync and an iPhone can give you access to internet radio, YouTube, Apple Music, Spotify, etc. on the move. While Shairport Sync is no substitute for CarPlay, the audio quality is often much better than Bluetooth. Your passengers can enjoy movies with the soundtrack on the car speakers. You can even listen to Siri's traffic directions on your car audio. +# Shairport Sync for Cars +If your car audio has an AUX input, you can get AirPlay in your car using Shairport Sync. Together, Shairport Sync and an iPhone can give you access to internet radio, YouTube, Apple Music, Spotify, etc. on the move. While Shairport Sync is no substitute for CarPlay, the audio quality is often much better than Bluetooth. ## The Basic Idea @@ -14,10 +14,12 @@ Note that Android devices can not, so far, do this trick of using the two networ ## Example -In this example, a Raspberry Pi Zero W and a Pimoroni PHAT DAC are used. This combination has been tested for over two years. Please note that some of the details of setting up networks are specific to the version of Linux used -- Raspbian Stretch or later. +In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shairport Sync will be built to support AirPlay 2, but you will also be shown how to build it for "classic" AirPlay (aka AirPlay 1) if you prefer. BTW, the requirments for classic Airplay are less stringent: for classic AirPlay, a Pi Zero W is powerful enough, and Raspbian Stretch (Lite) or later is fine. + +Please note that some of the details of setting up networks are specific to the version of Linux used -- Rasberry Pi OS (Bullseye) Lite or later. ### Prepare the initial SD Image -* Download the latest version of Raspbian Lite -- Stretch Lite of 2018-03-13 at the time of writing -- and install it onto an SD Card. +* Download the latest version of Raspberry Pi OS (Lite) -- Bullseye (Lite) of 2022-04-04 at the time of writing -- and install it onto an SD Card. The Lite version is preferable to the Desktop version as it doesn't include a sound server like PulseAudio or PipeWire that can prevent direct access to the audio output device. * Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. Both of these need a little modification. * Enable SSH service by creating a file called `ssh` on the `boot` drive. To do this, mount the drive and CD to its `boot` partition (since my username is `mike`, the drive is at `/media/mike/boot`): ``` @@ -44,23 +46,45 @@ The first thing to do on a Pi would be to use the `raspi-config` tool to expand # apt-get upgrade ``` -### Shairport Sync -First, install the packages needed by Shairport Sync: +### Build and Install +Let's get the tools and libraries for building and installing Shairport Sync (and NQPTP). + ``` -# apt install --no-install-recommends build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev +# apt install --no-install-recommends build-essential git xmltoman autoconf automake libtool \ + libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev \ + libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd ``` -Next, download Shairport Sync, configure it, compile and install it: +If you are building classic Shairport Sync, the list of packages is shorter: +``` +# apt-get install --no-install-recommends build-essential git xmltoman autoconf automake libtool \ + libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev +``` + +#### NQPTP +Skip this section if you are building classic Shairport Sync – NQPTP is not needed for classic Shairport Sync. + +Download, install, enable and start NQPTP from [here](https://github.com/mikebrady/nqptp). + +#### Shairport Sync +Download Shairport Sync, check out the `development` branch and configure, compile and install it. + +* Omit the `--with-airplay-2` from the `./configure` options if you are building classic Shairport Sync. + ``` $ git clone https://github.com/mikebrady/shairport-sync.git $ cd shairport-sync +$ git checkout development $ autoreconf -fi -$ ./configure --sysconfdir=/etc --with-alsa --with-avahi --with-ssl=openssl --with-soxr --with-systemd +$ ./configure --sysconfdir=/etc --with-alsa \ + --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2 $ make -$ sudo make install +# make install ``` -*Do not* enable Shairport Sync to automatically start at boot time -- startup is organised differently. +The `autoreconf` step may take quite a while – please be patient! -Third, finish by configuring Shairport Sync. +**Note:** *Do not* enable Shairport Sync to start automatically at boot time -- later on in this installation, we will arrange for it to start after the network has been set up. + +### Configure Shairport Sync Here are the important options for the Shairport Sync configuration file at `/etc/shairport-sync.conf`: ``` // Sample Configuration File for Shairport Sync for Car Audio with a Pimoroni PHAT From 248a9903d42b2ee0b3a4100a6b088469065a12d2 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:49:36 +0100 Subject: [PATCH 02/16] Update CAR INSTALL.md --- CAR INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 638c146a..0c5c4e05 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -14,7 +14,7 @@ Note that Android devices can not, so far, do this trick of using the two networ ## Example -In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shairport Sync will be built to support AirPlay 2, but you will also be shown how to build it for "classic" AirPlay (aka AirPlay 1) if you prefer. BTW, the requirments for classic Airplay are less stringent: for classic AirPlay, a Pi Zero W is powerful enough, and Raspbian Stretch (Lite) or later is fine. +In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shairport Sync will be built for AirPlay 2 operation, but you will also see how to build it for "classic" AirPlay (aka AirPlay 1) operation if you prefer. The requirments for classic Airplay are less stringent: a Pi Zero W is powerful enough, and Raspbian Stretch (Lite) or later is fine. Please note that some of the details of setting up networks are specific to the version of Linux used -- Rasberry Pi OS (Bullseye) Lite or later. From 8de767fc365bba6de1c161f8bb391fc6a170b429 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:52:12 +0100 Subject: [PATCH 03/16] Update CAR INSTALL.md --- CAR INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 0c5c4e05..6bebe638 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -5,9 +5,9 @@ If your car audio has an AUX input, you can get AirPlay in your car using Shairp The basic idea is to use a small Linux computer to create an isolated WiFi network for the car and to run Shairport Sync on it to provide an AirPlay service. The audio goes via a DAC to the AUX input of your car audio system. -The car WiFi network you create is isolated and local to your car, and since it isn't connected to the Internet, you don't really need to secure it with a password. Likewise, you don't really have to use a password to connect to the AirPlay service. +The car WiFi network you create is isolated and local to your car, and since it isn't connected to the Internet, you don't really need to secure it with a password. -When an iPhone or an iPad with cellular capability is connected to an isolated WiFi network like this, it can use its cellular connection to access the Internet. +When an iPhone or an iPad with cellular capability is connected to an isolated WiFi network, it can use its cellular connection to access the Internet. This means it can connect to internet radio, YouTube, Apple Music, Spotify, etc. over the cellular network and play the audio through the car network to the AirPlay service provided by Shairport Sync. Note that Android devices can not, so far, do this trick of using the two networks simultaneously. From 4473bc329d3bf299fb87845fec513d5158eb2892 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:22:19 +0100 Subject: [PATCH 04/16] Update CAR INSTALL.md --- CAR INSTALL.md | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 6bebe638..83130db0 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -19,28 +19,18 @@ In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shair Please note that some of the details of setting up networks are specific to the version of Linux used -- Rasberry Pi OS (Bullseye) Lite or later. ### Prepare the initial SD Image -* Download the latest version of Raspberry Pi OS (Lite) -- Bullseye (Lite) of 2022-04-04 at the time of writing -- and install it onto an SD Card. The Lite version is preferable to the Desktop version as it doesn't include a sound server like PulseAudio or PipeWire that can prevent direct access to the audio output device. -* Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. Both of these need a little modification. -* Enable SSH service by creating a file called `ssh` on the `boot` drive. To do this, mount the drive and CD to its `boot` partition (since my username is `mike`, the drive is at `/media/mike/boot`): -``` -$ touch ssh -``` -* Also in the `boot` drive, edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: +* Download the latest version of Raspberry Pi OS (Lite) -- Bullseye (Lite) of 2022-04-04 at the time of writing -- and install it onto an SD Card using `Raspberry Pi Imager`. The Lite version is preferable to the Desktop version as it doesn't include a sound server like PulseAudio or PipeWire that can prevent direct access to the audio output device. +* Before writing the image to the card, use the Settings control on `Raspberry Pi Imager`. You can specify a wireless network that the Pi will connect to it when it boots up. Later on the Pi will be configured to start its own isolated network. +* Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. +* CD to the `boot` drive (since my username is `mike`, it will be at `/media/mike/boot`): +* Edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: ``` dtoverlay=hifiberry-dac ``` -* Next, some modifications need to be done to the `rootfs` drive to make the Pi connect to your main WiFi network. (This is a temporary measure to enable you to connect the Pi to your main network so that you can do all the software installation and updating of the software necessary. Later, the Pi will be configured to start its own isolated network.) On the `rootfs` drive, edit the file `etc/wpa_supplicant/wpa_supplicant.conf` (you'll need root privileges) and add the name and password of your main WiFi network (substitute your own network name and password in, but keep the quotation marks): -``` -network={ - ssid="Network Name" - psk="Password" -} - -``` -Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at `raspberrypi.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. +Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname yoou gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. ### Boot, Configure, Update -The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. It might be useful to change the `hostname` too. Next, do the usual update and upgrade: +The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. Next, do the usual update and upgrade: ``` # apt-get update # apt-get upgrade From 3f7806f5c78ea1062aeb57ea8f0d919ddfd1dff5 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:23:19 +0100 Subject: [PATCH 05/16] Update CAR INSTALL.md --- CAR INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 83130db0..f004748a 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -27,7 +27,7 @@ Please note that some of the details of setting up networks are specific to the ``` dtoverlay=hifiberry-dac ``` -Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname yoou gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. + Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname you gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. ### Boot, Configure, Update The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. Next, do the usual update and upgrade: From e3197adc039fd0f5ec854660d5b38453088c4069 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:23:56 +0100 Subject: [PATCH 06/16] Update CAR INSTALL.md --- CAR INSTALL.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index f004748a..4ceb24ce 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -27,7 +27,8 @@ Please note that some of the details of setting up networks are specific to the ``` dtoverlay=hifiberry-dac ``` - Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname you gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. + + Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname you gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. ### Boot, Configure, Update The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. Next, do the usual update and upgrade: From 3f2367db8bf95e590b023de81c4a0f1f80c8fce2 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:28:20 +0100 Subject: [PATCH 07/16] Update CAR INSTALL.md --- CAR INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 4ceb24ce..b8e8360f 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -24,9 +24,9 @@ Please note that some of the details of setting up networks are specific to the * Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. * CD to the `boot` drive (since my username is `mike`, it will be at `/media/mike/boot`): * Edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: -``` -dtoverlay=hifiberry-dac -``` + ``` + dtoverlay=hifiberry-dac + ``` Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname you gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. From aa83a7ad399267dccc26888c1d27bb88e4de3c6d Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 16:30:05 +0100 Subject: [PATCH 08/16] Update CAR INSTALL.md --- CAR INSTALL.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index b8e8360f..cd76b613 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -28,7 +28,10 @@ Please note that some of the details of setting up networks are specific to the dtoverlay=hifiberry-dac ``` - Close the file and carefully dismount and eject the two drives. Remove the SD card from the Linux machine, insert it into the Pi and reboot. After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the hostname you gave it appended with `.local`, e.g. if the hostname is `bmw` then try `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. +* Close the file and carefully dismount and eject the two drives. +* Remove the SD card from the Linux machine, insert it into the Pi and reboot. + +After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the `.local`, e.g. if the hostname is `bmw` then use `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. ### Boot, Configure, Update The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. Next, do the usual update and upgrade: From a9a5bde4f5956db12b47cb084fb31b1937fe85e4 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:27:07 +0100 Subject: [PATCH 09/16] Update CAR INSTALL.md --- CAR INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index cd76b613..3db3f41b 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -20,7 +20,7 @@ Please note that some of the details of setting up networks are specific to the ### Prepare the initial SD Image * Download the latest version of Raspberry Pi OS (Lite) -- Bullseye (Lite) of 2022-04-04 at the time of writing -- and install it onto an SD Card using `Raspberry Pi Imager`. The Lite version is preferable to the Desktop version as it doesn't include a sound server like PulseAudio or PipeWire that can prevent direct access to the audio output device. -* Before writing the image to the card, use the Settings control on `Raspberry Pi Imager`. You can specify a wireless network that the Pi will connect to it when it boots up. Later on the Pi will be configured to start its own isolated network. +* Before writing the image to the card, use the Settings control on `Raspberry Pi Imager` to set hostname, enable SSH and provide a username and password to use while building the system. Similarly, you can specify a wireless network the Pi will connect to while building the system. Later on the Pi will be configured to start its own isolated network. * Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. * CD to the `boot` drive (since my username is `mike`, it will be at `/media/mike/boot`): * Edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: From e312c0cda29d78d1624b73fbf66d519a04d9cf74 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:43:21 +0100 Subject: [PATCH 10/16] Update CAR INSTALL.md --- CAR INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index 3db3f41b..ee258e58 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -57,7 +57,7 @@ If you are building classic Shairport Sync, the list of packages is shorter: #### NQPTP Skip this section if you are building classic Shairport Sync – NQPTP is not needed for classic Shairport Sync. -Download, install, enable and start NQPTP from [here](https://github.com/mikebrady/nqptp). +Download, install, enable and start NQPTP from [here](https://github.com/mikebrady/nqptp) following the guide for Linux. #### Shairport Sync Download Shairport Sync, check out the `development` branch and configure, compile and install it. From 08de8a40842fdb780f0480b773930644ef1b2582 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 15 Aug 2022 18:03:45 +0100 Subject: [PATCH 11/16] Update CAR INSTALL.md --- CAR INSTALL.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index ee258e58..bd2de1fa 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -128,8 +128,8 @@ ssid=BMW # Use the 2.4GHz band hw_mode=g -# Use channel 6 -channel=9 +# Use channel 6 or some other channel of your choice +channel=6 # Enable 802.11n ieee80211n=1 @@ -160,6 +160,7 @@ ignore_broadcast_ssid=0 # Use AES, instead of TKIP #rsn_pairwise=CCMP + ``` #### Configure DHCP server @@ -201,6 +202,7 @@ Configure the startup sequence by adding commands to `/etc/rc.local` to start `h /bin/systemctl start shairport-sync exit 0 + ``` As you can see, the effect of these commands is to start the WiFi transmitter, give the base station the IP address `10.0.10.1`, start a DHCP server and finally start the Shairport Sync service. From 30510e72f1793b737c17fa23a86c6890be0a7cd3 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 16 Aug 2022 09:25:53 +0100 Subject: [PATCH 12/16] Remove a very noisy and redundant debug message. --- audio_alsa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/audio_alsa.c b/audio_alsa.c index 4ee19bcc..93c25689 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -1456,9 +1456,9 @@ int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay, // delay_temp = 0; ret = 0; } - } else { - debug(1, "alsa_handle is NULL in standard_delay_and_status."); - } + } // else { + // debug(1, "alsa_handle is NULL in standard_delay_and_status."); + // } stall_monitor_start_time = 0; // zero if not initialised / not started / zeroed by flush stall_monitor_frame_count = 0; // set to delay at start of time, incremented by any writes From 174556f05486393a9f2b4ef80e144f5b9b545dc3 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 16 Aug 2022 09:26:35 +0100 Subject: [PATCH 13/16] Remove a few causes of "possibly uninitialised" warnings. --- player.c | 4 ++-- rtp.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/player.c b/player.c index 5f124680..15ee9671 100644 --- a/player.c +++ b/player.c @@ -1746,8 +1746,8 @@ void *player_thread_func(void *arg) { rtsp_conn_info *conn = (rtsp_conn_info *)arg; uint64_t previous_frames_played; - uint64_t previous_raw_measurement_time; - uint64_t previous_corrected_measurement_time; + uint64_t previous_raw_measurement_time = 0; // initialised to avoid a "possibly uninitialised" warning + uint64_t previous_corrected_measurement_time = 0; // initialised to avoid a "possibly uninitialised" warning int previous_frames_played_valid = 0; // pthread_cleanup_push(player_thread_initial_cleanup_handler, arg); diff --git a/rtp.c b/rtp.c index 844f55fe..247f1689 100644 --- a/rtp.c +++ b/rtp.c @@ -2362,7 +2362,7 @@ void *rtp_buffered_audio_processor(void *arg) { uint8_t *pcm_audio = NULL; // the S16 output unsigned char *data_to_process; ssize_t data_remaining; - uint32_t seq_no; // audio packet number + uint32_t seq_no = 0; // audio packet number. Initialised to avoid a "possibly uninitialised" warning. // uint32_t previous_seq_no = 0; int new_buffer_needed = 0; ssize_t nread; @@ -2380,10 +2380,10 @@ void *rtp_buffered_audio_processor(void *arg) { uint64_t blocks_read_since_flush = 0; int flush_requested = 0; - uint32_t timestamp; + uint32_t timestamp = 0; // initialised to avoid a "possibly uninitialised" warning. int streaming_has_started = 0; int play_enabled = 0; - uint32_t flush_from_timestamp; + uint32_t flush_from_timestamp = 0; // initialised to avoid a "possibly uninitialised" warning. double requested_lead_time = 0.0; // normal lead time minimum -- maybe it should be about 0.1 // wait until our timing information is valid From d34db2a4b683cb6571ff0dbb84a9f5b263493f8f Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 16 Aug 2022 09:41:36 +0100 Subject: [PATCH 14/16] Update CAR INSTALL.md --- CAR INSTALL.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CAR INSTALL.md b/CAR INSTALL.md index bd2de1fa..166eb9f0 100644 --- a/CAR INSTALL.md +++ b/CAR INSTALL.md @@ -1,5 +1,5 @@ # Shairport Sync for Cars -If your car audio has an AUX input, you can get AirPlay in your car using Shairport Sync. Together, Shairport Sync and an iPhone can give you access to internet radio, YouTube, Apple Music, Spotify, etc. on the move. While Shairport Sync is no substitute for CarPlay, the audio quality is often much better than Bluetooth. +If your car audio has an AUX input, you can get AirPlay in your car using Shairport Sync. Together, Shairport Sync and an iPhone or an iPad with cellular capability can give you access to internet radio, YouTube, Apple Music, Spotify, etc. on the move. While Shairport Sync is no substitute for CarPlay, the audio quality is often much better than Bluetooth. ## The Basic Idea @@ -14,24 +14,24 @@ Note that Android devices can not, so far, do this trick of using the two networ ## Example -In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shairport Sync will be built for AirPlay 2 operation, but you will also see how to build it for "classic" AirPlay (aka AirPlay 1) operation if you prefer. The requirments for classic Airplay are less stringent: a Pi Zero W is powerful enough, and Raspbian Stretch (Lite) or later is fine. +In this example, a Raspberry Pi Zero 2 W and a Pimoroni PHAT DAC are used. Shairport Sync will be built for AirPlay 2 operation, but you can build it for "classic" AirPlay (aka AirPlay 1) operation if you prefer. A Pi Zero W is powerful enough for classic AirPlay. Please note that some of the details of setting up networks are specific to the version of Linux used -- Rasberry Pi OS (Bullseye) Lite or later. ### Prepare the initial SD Image * Download the latest version of Raspberry Pi OS (Lite) -- Bullseye (Lite) of 2022-04-04 at the time of writing -- and install it onto an SD Card using `Raspberry Pi Imager`. The Lite version is preferable to the Desktop version as it doesn't include a sound server like PulseAudio or PipeWire that can prevent direct access to the audio output device. -* Before writing the image to the card, use the Settings control on `Raspberry Pi Imager` to set hostname, enable SSH and provide a username and password to use while building the system. Similarly, you can specify a wireless network the Pi will connect to while building the system. Later on the Pi will be configured to start its own isolated network. -* Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. -* CD to the `boot` drive (since my username is `mike`, it will be at `/media/mike/boot`): -* Edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: - ``` - dtoverlay=hifiberry-dac - ``` - -* Close the file and carefully dismount and eject the two drives. +* Before writing the image to the card, use the Settings control on `Raspberry Pi Imager` to set hostname, enable SSH and provide a username and password to use while building the system. Similarly, you can specify a wireless network the Pi will connect to while building the system. Later on the Pi will be configured to start its own isolated network. +* The next few steps are to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used. If you do not need to add an overlay, skip these steps. + * Mount the card on a Linux machine. Two drives should appear -- a `boot` drive and a `rootfs` drive. + * `cd` to the `boot` drive (since my username is `mike`, it will be `$ cd /media/mike/boot`). + * Edit the `config.txt` file to add the overlay needed for the sound card. This may not be necessary in your case, but in this example a Pimoroni PHAT is being used and it needs the following entry to be added: + ``` + dtoverlay=hifiberry-dac + ``` + * Close the file and carefully dismount and eject the two drives. *Be sure to dismount and eject the drives properly; otherwise they may be corrupted.* * Remove the SD card from the Linux machine, insert it into the Pi and reboot. -After a short time, the Pi should appear on your network and you can SSH into it. To check that it has appeared on the network, try to ping it at the `.local`, e.g. if the hostname is `bmw` then use `bmw.local`. It may take a minute or so to appear. Once it has appeared on your network you can SSH into it and configure it. +After a short time, the Pi should appear on your network -- it may take a minute or so. To check, try to `ping` it at the `.local`, e.g. if the hostname is `bmw` then use `$ ping bmw.local`. Once it has appeared, you can SSH into it and configure it. ### Boot, Configure, Update The first thing to do on a Pi would be to use the `raspi-config` tool to expand the file system to use the entire card. Next, do the usual update and upgrade: From 3c717b96b7f03206a07682365e6892a182182b5d Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 16 Aug 2022 09:47:14 +0100 Subject: [PATCH 15/16] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index f1f279ab..87c89659 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,3 +1,8 @@ +Version 4.1-dev-494-gd34db2a4 +==== +* The [CAR INSTALL.md](https://github.com/mikebrady/shairport-sync/blob/development/CAR%20INSTALL.md) guide has been updated for AirPlay 2 and for Raspberry Pi OS (Bullseye). +* A few noisy debug messages have been removed or quietened. + Version 4.1-dev-468-gcb03d5c6 ==== **Updates and Enhancements** From d6e2b91a83eae3673ad45ebead70d2b32f78b234 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:15:31 +0100 Subject: [PATCH 16/16] Update RELEASENOTES-DEVELOPMENT.md --- RELEASENOTES-DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASENOTES-DEVELOPMENT.md b/RELEASENOTES-DEVELOPMENT.md index 87c89659..df34badd 100644 --- a/RELEASENOTES-DEVELOPMENT.md +++ b/RELEASENOTES-DEVELOPMENT.md @@ -1,7 +1,7 @@ Version 4.1-dev-494-gd34db2a4 ==== * The [CAR INSTALL.md](https://github.com/mikebrady/shairport-sync/blob/development/CAR%20INSTALL.md) guide has been updated for AirPlay 2 and for Raspberry Pi OS (Bullseye). -* A few noisy debug messages have been removed or quietened. +* A few noisy debug messages have been removed or quietened. Thanks to [David Leibovic](https://github.com/dasl-) for [the report](https://github.com/mikebrady/shairport-sync/issues/1513). Version 4.1-dev-468-gcb03d5c6 ====