From: Charles <32498151+charlesomer@users.noreply.github.com> Date: Wed, 5 Oct 2022 21:45:23 +0000 (+0100) Subject: Docker build changes, github action updates. X-Git-Tag: 4.1-rc2~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0eb29bfd10765c0f6f9071fddad34ed16bc03ca7;p=thirdparty%2Fshairport-sync.git Docker build changes, github action updates. --- diff --git a/.github/workflows/docker-build-on-formal-release.yaml b/.github/workflows/docker-build-on-formal-release.yaml deleted file mode 100644 index fc698373..00000000 --- a/.github/workflows/docker-build-on-formal-release.yaml +++ /dev/null @@ -1,83 +0,0 @@ -# Builds & pushes a docker image when a "formal" release tag of the format X, X.Y or X.Y.Z occurs, where X, Y and Z are all numbers. -# It seems this yaml has to exist on the branch the tag refers to. - -# Thanks to Charles Omer for the workfow upon which this is based. - -# The following docker tags are created & pushed: -# trial, trial-classic -# not building 'latest' yet... - -name: Formal (X, X.Y or X.Y.Z) release tags -- docker build and push. - -on: - push: - tags: - - '[0-9]+\.[0-9]+\.[0-9]+' # e.g. 8.9.0 - - '[0-9]+\.[0-9]+' # e.g. 8.9 - - '[0-9]+' # e.g. 8 - - '[0-9]+\.[0-9]+rc[0-9]+' # e.g. 4.1rc0 - -env: - DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm64,linux/arm/v7 - -jobs: - main: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set SHAIRPORT_SYNC_BRANCH env. - run: | - raw=$(git branch -r --contains ${{ github.ref }}) - branch=${raw##*/} - echo "SHAIRPORT_SYNC_BRANCH=${branch}" >> $GITHUB_ENV - - - name: Set tag env - run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Determine NQPTP env (part 1). - if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }} - run: echo "NQPTP_BRANCH=development" >> $GITHUB_ENV - - - name: Determine NQPTP env (part 2). - if: ${{ env.SHAIRPORT_SYNC_BRANCH != 'development' }} - run: echo "NQPTP_BRANCH=main" >> $GITHUB_ENV - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Registry - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./docker/Dockerfile - platforms: ${{ env.DOCKER_PLATFORMS }} - push: true - tags: trial - build-args: | - SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} - NQPTP_BRANCH=${{ env.NQPTP_BRANCH }} - - - name: Build and push (Classic) - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./docker/classic/Dockerfile - platforms: ${{ env.DOCKER_PLATFORMS }} - push: true - tags: trial-classic - build-args: | - SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} diff --git a/.github/workflows/docker-build-on-push.yaml b/.github/workflows/docker-build-on-push.yaml index dca048e2..1d273cad 100644 --- a/.github/workflows/docker-build-on-push.yaml +++ b/.github/workflows/docker-build-on-push.yaml @@ -1,14 +1,19 @@ -# Builds & pushes a docker image when a commit is made to one of the branches specified below. -# Tag pattern: 'unstable-[BRANCH NAME]' & 'unstable-[BRANCH NAME]-classic' +# Builds a docker image when a commit is made. Also pushes the build if the branch is 'master' or 'development'. -name: Build and push docker image based on commit to specified branches. +# Tag pattern +# 'master' - latest, latest-classic +# 'development' - development, development-classic + +name: Build and push docker (commit) on: push: - branches: [ development ] + branches: + - '**' env: DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + NQPTP_BRANCH: main jobs: main: @@ -22,13 +27,16 @@ jobs: - name: Set SHAIRPORT_SYNC_BRANCH env. run: echo "SHAIRPORT_SYNC_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - - name: Determine NQPTP env (part 1). - if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }} - run: echo "NQPTP_BRANCH=development" >> $GITHUB_ENV + - name: Is branch "master"? + if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }} + run: | + echo "IMAGE_TAG_BASE=latest" >> $GITHUB_ENV - - name: Determine NQPTP env (part 2). - if: ${{ env.SHAIRPORT_SYNC_BRANCH != 'development' }} - run: echo "NQPTP_BRANCH=main" >> $GITHUB_ENV + - name: Is branch "development"? + if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }} + run: | + echo "NQPTP_BRANCH=development" >> $GITHUB_ENV + echo "IMAGE_TAG_BASE=development" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -43,33 +51,25 @@ jobs: username: ${{ secrets.DOCKER_REGISTRY_USER }} password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Set tag start (part 1). - if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }} - run: echo "IMAGE_TAG_BASE=unstable" >> $GITHUB_ENV - - - name: Set tag start (part 2). - if: ${{ env.SHAIRPORT_SYNC_BRANCH != 'master' }} - run: echo "IMAGE_TAG_BASE=unstable-${{ env.SHAIRPORT_SYNC_BRANCH }}" >> $GITHUB_ENV - - name: Build and push uses: docker/build-push-action@v2 with: context: ./ file: ./docker/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} - push: true + push: ${{ env.IMAGE_TAG_BASE != '' }} tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }} build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} NQPTP_BRANCH=${{ env.NQPTP_BRANCH }} - - name: Build and push (AirPlay 1) + - name: Build and push (classic) uses: docker/build-push-action@v2 with: context: ./ file: ./docker/classic/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} - push: true + push: ${{ env.IMAGE_TAG_BASE != '' }} tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}-classic build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} \ No newline at end of file diff --git a/.github/workflows/docker-build-on-tag.yaml b/.github/workflows/docker-build-on-tag.yaml index 6762a9bd..0e87ebd4 100644 --- a/.github/workflows/docker-build-on-tag.yaml +++ b/.github/workflows/docker-build-on-tag.yaml @@ -1,18 +1,22 @@ -# Builds & pushes a docker image when a tag occurs. -# It seems this yaml has to exist on the branch the tag refers to. +# Builds & pushes a docker image when a tag is created. +# Tag pattern: '[tag]' & '[tag]-classic' +# 'stable' & 'stable-classic' also, when master tagged. -# The following docker tags are created & pushed: -# [RELEASE TAG], [RELEASE TAG]-classic, +# Only pushes the tag when it matches one of the following patterns: +# X, X.Y or X.Y.Z -name: Build and push docker images on releases. +name: Build and push docker (tag) on: push: tags: - - '*' # Push events to every tag (not containing '/') + - '[0-9]+' # X + - '[0-9]+\.[0-9]+' # X.Y + - '[0-9]+\.[0-9]+\.[0-9]+' # X.Y.Z env: DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm64,linux/arm/v7 + NQPTP_BRANCH: main jobs: main: @@ -32,22 +36,23 @@ jobs: - name: Set tag env run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Determine NQPTP env (part 1). + - name: Is branch "master"? + if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }} + run: echo "STABLE_TAG=true" >> $GITHUB_ENV + + - name: Is branch "development"? if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }} - run: echo "NQPTP_BRANCH=development" >> $GITHUB_ENV - - - name: Determine NQPTP env (part 2). - if: ${{ env.SHAIRPORT_SYNC_BRANCH != 'development' }} - run: echo "NQPTP_BRANCH=main" >> $GITHUB_ENV + run: | + echo "NQPTP_BRANCH=development" >> $GITHUB_ENV - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to Docker Registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ${{ secrets.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} @@ -60,18 +65,22 @@ jobs: file: ./docker/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: true - tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }} + tags: | + ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }} + ${{ env.STABLE_TAG == 'true' && format('{0}:stable', secrets.DOCKER_IMAGE_NAME) || '' }} build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} NQPTP_BRANCH=${{ env.NQPTP_BRANCH }} - - name: Build and push (Classic) + - name: Build and push (classic) uses: docker/build-push-action@v2 with: context: ./ file: ./docker/classic/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: true - tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-classic + tags: | + ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-classic + ${{ env.STABLE_TAG == 'true' && format('{0}:stable-classic', secrets.DOCKER_IMAGE_NAME) || '' }} build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index b681ed3e..1dc654cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -267,9 +267,13 @@ if INSTALL_SYSTEMV INSTALL_SYSTEMV_TARGET = install-systemv-local +# watch out -- shairport-sync is created during the ./configure step and +# will be stored in a scripts folder in the _build_ folder +# which will be the source folder if you're not using a separate build folder + $(INSTALL_SYSTEMV_TARGET): scripts/shairport-sync $(INSTALL_USER_TARGET) install -d $(DESTDIR)$(sysconfdir)/init.d - [ -e $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || install -m 0644 $(top_srcdir)/scripts/shairport-sync $(DESTDIR)$(sysconfdir)/init.d + [ -e $(DESTDIR)$(sysconfdir)/init.d/shairport-sync ] || install -m 0755 scripts/shairport-sync $(DESTDIR)$(sysconfdir)/init.d endif # INSTALL_SYSTEMV @@ -283,9 +287,13 @@ endif # USE_AVAHI INSTALL_SYSTEMD_TARGET = install-systemd-local +# watch out -- shairport-sync.service is created during the ./configure step and +# will be stored in a scripts folder in the _build_ folder +# which will be the source folder if you're not using a separate build folder + $(INSTALL_SYSTEMD_TARGET): scripts/$(SYSTEMD_SERVICE) $(INSTALL_USER_TARGET) install -d $(DESTDIR)$(systemdsystemunitdir) - [ -e $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || install -m 0644 $(top_srcdir)/scripts/$(SYSTEMD_SERVICE) $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service + [ -e $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service ] || install -m 0644 scripts/$(SYSTEMD_SERVICE) $(DESTDIR)$(systemdsystemunitdir)/shairport-sync.service endif # INSTALL_SYSTEMD diff --git a/audio_alsa.c b/audio_alsa.c index fc53ee65..62db843f 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -1850,7 +1850,8 @@ static int do_close() { // debug(1,"alsa: do_close() -- closing the output device"); if ((derr = snd_pcm_drop(alsa_handle))) debug(1, "Error %d (\"%s\") dropping output device.", derr, snd_strerror(derr)); - usleep(5000); // this make the function pthread cancellable + usleep(10000); // wait for the hardware to do its trick. BTW, this make the function pthread + // cancellable if ((derr = snd_pcm_hw_free(alsa_handle))) debug(1, "Error %d (\"%s\") freeing the output device hardware.", derr, snd_strerror(derr)); debug(2, "alsa: do_close() -- closing alsa handle"); @@ -2061,9 +2062,12 @@ static void *alsa_buffer_monitor_thread_code(__attribute__((unused)) void *arg) int error_count = 0; int error_detected = 0; int okb = -1; - while (error_detected == - 0) { // if too many play errors occur early on, we will turn off the disable stanby mode + // if too many play errors occur early on, we will turn off the disable standby mode + while (error_detected == 0) { + int keep_dac_busy_has_just_gone_off = 0; if (okb != config.keep_dac_busy) { + if ((okb != 0) && (config.keep_dac_busy == 0)) + keep_dac_busy_has_just_gone_off = 1; debug(2, "keep_dac_busy is now \"%s\"", config.keep_dac_busy == 0 ? "no" : "yes"); okb = config.keep_dac_busy; } @@ -2081,7 +2085,7 @@ static void *alsa_buffer_monitor_thread_code(__attribute__((unused)) void *arg) if (do_open(1) == 0) // no automatic setup of rate and speed if necessary debug(2, "alsa: alsa_buffer_monitor_thread_code() -- output device opened; " "alsa_backend_state => abm_connected"); - } else if ((alsa_backend_state == abm_connected) && (config.keep_dac_busy == 0)) { + } else if ((alsa_backend_state != abm_disconnected) && (keep_dac_busy_has_just_gone_off != 0)) { stall_monitor_start_time = 0; // frame_index = 0; // measurement_data_is_valid = 0; diff --git a/docker/README.md b/docker/README.md index acabc123..2b27e77f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,21 +2,32 @@ Available at: https://hub.docker.com/r/mikebrady/shairport-sync -Please note if you want the development version of the image including Airplay 2 support, please pull the image with the ```unstable development``` tag using the following command: -``` -docker pull mikebrady/shairport-sync:unstable-development +The following docker tags are available: ``` +[tag] +[tag]-classic + +(build from newest tag) +stable +stable-classic -When using the below commands, you should replace mikebrady/shairport-sync with mikbrady/shairport-sync:unstable-development. +(latest build from master) +latest +latest-classic + +(latest build from development) +development +development-classic +``` ## Example Docker Compose File See the `docker-compose.yaml` file in this folder for an example. -## Docker Run +## Example Docker Run ``` $ docker run -d --restart unless-stopped --net host --device /dev/snd \ - mikebrady/shairport-sync + mikebrady/shairport-sync: ``` ### Options @@ -24,7 +35,7 @@ $ docker run -d --restart unless-stopped --net host --device /dev/snd \ You can change the default commands passed to Shairport Sync. Here is an example: ``` $ docker run -d --restart unless-stopped --net host --device /dev/snd \ - mikebrady/shairport-sync:unstable-development shairport-sync -v \ + mikebrady/shairport-sync: shairport-sync -v \ --statistics -a DenSystem -d hw:0 -c PCM ``` This will sent audio to alsa hardware device `hw:0` and make use of the that device's mixer control called `PCM`. The service will be visible as `DenSystem` on the network. @@ -53,4 +64,4 @@ Requires the following secrets to be set in the repo: - `DOCKER_REGISTRY` - docker.io if using Docker Hub, else set to your registry URL. - `DOCKER_REGISTRY_TOKEN` - Access token for your registry. - `DOCKER_REGISTRY_USER` - Login user for your registry. -- `DOCKER_IMAGE_NAME` - The name of the image, for example `your-registry.com/shairport-sync` or just `your-username/shairport-sync` if using Docker Hub. +- `DOCKER_IMAGE_NAME` - The name of the image, for example `your-registry.com/shairport-sync` or just `your-username/shairport-sync` if using Docker Hub. \ No newline at end of file diff --git a/docker/airplay1/Dockerfile b/docker/airplay1/Dockerfile deleted file mode 100644 index e60fd0b5..00000000 --- a/docker/airplay1/Dockerfile +++ /dev/null @@ -1,103 +0,0 @@ -FROM alpine:3.12 AS builder-base -# General Build System: -RUN apk -U add \ - git \ - build-base \ - autoconf \ - automake \ - libtool \ - dbus \ - su-exec \ - alsa-lib-dev \ - libdaemon-dev \ - popt-dev \ - mbedtls-dev \ - soxr-dev \ - avahi-dev \ - libconfig-dev \ - libsndfile-dev \ - mosquitto-dev \ - xmltoman - -# ALAC Build System: -FROM builder-base AS builder-alac - -RUN git clone https://github.com/mikebrady/alac -WORKDIR alac -RUN autoreconf -fi -RUN ./configure -RUN make -RUN make install - -# Shairport Sync Build System: -FROM builder-base AS builder-sps - -# This will be modified by the Github Action Workflow and is required -# to ensure the correct branch is being used. -ARG SHAIRPORT_SYNC_BRANCH -RUN test -n "$SHAIRPORT_SYNC_BRANCH" - -COPY --from=builder-alac /usr/local/lib/libalac.* /usr/local/lib/ -COPY --from=builder-alac /usr/local/lib/pkgconfig/alac.pc /usr/local/lib/pkgconfig/alac.pc -COPY --from=builder-alac /usr/local/include /usr/local/include - -WORKDIR shairport-sync -COPY . . -RUN git checkout "$SHAIRPORT_SYNC_BRANCH" -RUN autoreconf -fi -RUN ./configure \ - --with-alsa \ - --with-dummy \ - --with-pipe \ - --with-stdout \ - --with-avahi \ - --with-ssl=mbedtls \ - --with-soxr \ - --sysconfdir=/etc \ - --with-dbus-interface \ - --with-mpris-interface \ - --with-mqtt-client \ - --with-apple-alac \ - --with-convolution -RUN make -j $(nproc) -RUN make install - -# Shairport Sync Runtime System: -FROM alpine:3.12 - -RUN apk -U add \ - alsa-lib \ - dbus \ - popt \ - glib \ - mbedtls \ - soxr \ - avahi \ - libconfig \ - libsndfile \ - mosquitto-libs \ - su-exec \ - libgcc \ - libgc++ - -RUN rm -rf /lib/apk/db/* - -COPY --from=builder-alac /usr/local/lib/libalac.* /usr/local/lib/ -COPY --from=builder-sps /etc/shairport-sync* /etc/ -COPY --from=builder-sps /etc/dbus-1/system.d/shairport-sync-dbus.conf /etc/dbus-1/system.d/ -COPY --from=builder-sps /etc/dbus-1/system.d/shairport-sync-mpris.conf /etc/dbus-1/system.d/ -COPY --from=builder-sps /usr/local/bin/shairport-sync /usr/local/bin/shairport-sync - -# Create non-root user for running the container -- running as the user 'shairport-sync' also allows -# Shairport Sync to provide the D-Bus and MPRIS interfaces within the container - -RUN addgroup shairport-sync -RUN adduser -D shairport-sync -G shairport-sync - -# Add the shairport-sync user to the pre-existing audio group, which has ID 29, for access to the ALSA stuff -RUN addgroup -g 29 docker_audio && addgroup shairport-sync docker_audio - -COPY ./docker/airplay1/start.sh / -RUN chmod +x /start.sh - -ENTRYPOINT [ "/start.sh" ] diff --git a/docker/airplay1/README.md b/docker/airplay1/README.md deleted file mode 100644 index 094a7429..00000000 --- a/docker/airplay1/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Original AirPlay 1 Only Docker Image - -## Basic Usage - -``` -$ docker run -d --restart unless-stopped --net host --device /dev/snd \ - mikebrady/shairport-sync -``` -The above command will run Shairport Sync as a daemon in a Docker container, accessing the computer's ALSA audio infrastructure. It will send audio to the default output device and make no use of any hardware mixers the default device might have. The AirPlay service name will be the host's `hostname` with the first letter capitalised, e.g. `Ubuntu`. - -## Options - -Any options you add to the command above will be passed to Shairport Sync. Here is an example: -``` -$ docker run -d --restart unless-stopped --net host --device /dev/snd \ - mikebrady/shairport-sync -a DenSystem -- -d hw:0 -c PCM -``` -This will sent audio to alsa hardware device `hw:0` and make use of the that device's mixer control called `PCM`. The service will be visible as `DenSystem` on the network. - -## Configuration File - -Edit the configuration file `/etc/shairport-sync.conf` in the container (or use the `-v` option to mirror an external copy of `shairport-sync.conf` in to `/etc/shairport-sync.conf`) to get access to the full range of configuration options. \ No newline at end of file diff --git a/docker/airplay1/start.sh b/docker/airplay1/start.sh deleted file mode 100644 index 5e24ff59..00000000 --- a/docker/airplay1/start.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -rm -rf /var/run/dbus.pid -#mkdir -p /var/run/dbus - -dbus-uuidgen --ensure -dbus-daemon --system - -avahi-daemon --daemonize --no-chroot - -su-exec shairport-sync shairport-sync "$@" \ No newline at end of file diff --git a/docker/classic/README.md b/docker/classic/README.md index 4dd3bf76..09ac8872 100644 --- a/docker/classic/README.md +++ b/docker/classic/README.md @@ -1,3 +1,3 @@ # Classic (AirPlay 1 Only) Docker Image -See the [Shairport Sync Docker Hub Repo](https://hub.docker.com/r/mikebrady/shairport-sync) for available tags. +See the [Shairport Sync Docker Hub Repo](https://hub.docker.com/r/mikebrady/shairport-sync) for available tags. \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 8877d0d0..6b2394a1 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -2,7 +2,7 @@ services: shairport-sync: - image: mikebrady/shairport-sync + image: mikebrady/shairport-sync: network_mode: host restart: unless-stopped devices: diff --git a/rtsp.c b/rtsp.c index d61ffeb1..76395df9 100644 --- a/rtsp.c +++ b/rtsp.c @@ -1275,7 +1275,9 @@ void clear_ptp_clock() { ssize_t read_from_rtsp_connection(rtsp_conn_info *conn, void *buf, size_t count) { // first try to read with a timeout, to see if there is any traffic... - ssize_t response = timed_read_from_rtsp_connection(conn, 10000000000L, buf, count); + // ssize_t response = timed_read_from_rtsp_connection(conn, 20000000000L, buf, count); + // actually don't use a timeout -- OwnTone doesn't supply regular traffic. + ssize_t response = timed_read_from_rtsp_connection(conn, 0, buf, count); if ((response == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { if (conn->rtsp_link_is_idle == 0) { debug(1, "Connection %d: RTSP connection is idle.", conn->connection_number); @@ -1622,7 +1624,7 @@ void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) if (conn->player_thread) warn("Connection %d: RECORD: Duplicate RECORD message -- ignored", conn->connection_number); else { - debug(1, "Connection %d: AP1 ALAC Stream, from %s:%u to self at %s:%u.", + debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.", conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, conn->self_ip_string, conn->self_rtsp_port); activity_monitor_signify_activity(1); @@ -2830,6 +2832,15 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) plist_t messagePlist = plist_from_rtsp_content(req); plist_t setupResponsePlist = plist_new_dict(); resp->respcode = 400; + + // see if we can get a name for the client + char *clientNameString = NULL; + plist_t nameItem = plist_dict_get_item(messagePlist, "name"); + if (nameItem != NULL) { + plist_get_string_val(nameItem, &clientNameString); + } else { + clientNameString = strdup(""); + } // see if the incoming plist contains a "streams" array plist_t streams = plist_dict_get_item(messagePlist, "streams"); @@ -2847,8 +2858,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) plist_get_string_val(timingProtocol, &timingProtocolString); if (timingProtocolString) { if (strcmp(timingProtocolString, "PTP") == 0) { - debug(2, "Connection %d: AP2 PTP connection from %s:%u to self at %s:%u.", - conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, + debug(1, "Connection %d: AP2 PTP connection from %s:%u (\"%s\") to self at %s:%u.", + conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, conn->self_ip_string, conn->self_rtsp_port); conn->airplay_stream_category = ptp_stream; conn->timing_type = ts_ptp; @@ -2862,20 +2873,24 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) send_ssnc_metadata('svip', conn->self_ip_string, strlen(conn->self_ip_string), 1); #endif } else if (strcmp(timingProtocolString, "NTP") == 0) { - debug(1, "Connection %d: SETUP: NTP setup detected.", conn->connection_number); + debug(1, "Connection %d: SETUP: NTP setup from %s:%u (\"%s\") to self at %s:%u.", + conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, + conn->self_ip_string, conn->self_rtsp_port); conn->airplay_stream_category = ntp_stream; conn->timing_type = ts_ntp; } else if (strcmp(timingProtocolString, "None") == 0) { - debug(2, "Connection %d: SETUP: a \"None\" setup detected.", conn->connection_number); + debug(3, "Connection %d: SETUP: a \"None\" setup detected from %s:%u (\"%s\") to self at %s:%u.", + conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, + conn->self_ip_string, conn->self_rtsp_port); // now check to see if it's got the "isRemoteControlOnly" item and check it's true plist_t isRemoteControlOnly = plist_dict_get_item(messagePlist, "isRemoteControlOnly"); if (isRemoteControlOnly != NULL) { uint8_t isRemoteControlOnlyBoolean = 0; plist_get_bool_val(isRemoteControlOnly, &isRemoteControlOnlyBoolean); if (isRemoteControlOnlyBoolean != 0) { - debug(2, "Connection %d: Remote Control connection from %s:%u to self at %s:%u.", - conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, - conn->self_ip_string, conn->self_rtsp_port); + debug(1, "Connection %d: Remote Control connection from %s:%u (\"%s\") to self at %s:%u.", + conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, clientNameString, + conn->self_ip_string, conn->self_rtsp_port); conn->airplay_stream_category = remote_control_stream; } else { debug(1, @@ -3354,6 +3369,8 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) msg_add_header(resp, "Content-Type", "application/x-apple-binary-plist"); } plist_free(messagePlist); + if (clientNameString != NULL) + free(clientNameString); debug_log_rtsp_message(2, " SETUP response", resp); } #endif @@ -3521,14 +3538,16 @@ void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *req, debug(2, "Connection %d: request to set AirPlay Volume to: %f.", conn->connection_number, volume); // if we are playing, go ahead and change the volume - lock_player(); - config.airplay_volume = volume; - if (playing_conn == conn) - player_volume(volume, conn); - unlock_player(); #ifdef CONFIG_DBUS_INTERFACE if (dbus_service_is_running()) { - shairport_sync_set_volume(shairportSyncSkeleton, config.airplay_volume); + shairport_sync_set_volume(shairportSyncSkeleton, volume); + } else { +#endif + lock_player(); + if (playing_conn == conn) + player_volume(volume, conn); + unlock_player(); +#ifdef CONFIG_DBUS_INTERFACE } #endif } else if (strncmp(cp, "progress: ", strlen("progress: ")) == @@ -4407,7 +4426,9 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag #ifdef CONFIG_AIRPLAY_2 conn->airplay_type = ap_1; conn->timing_type = ts_ntp; - debug(1, "Connection %d. AirPlay 1 Audio Stream Detected.", conn->connection_number); + debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.", + conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, + conn->self_ip_string, conn->self_rtsp_port); #endif conn->stream.type = ast_unknown; @@ -5460,7 +5481,7 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) { inet_ntop(conn->connection_ip_family, self_addr, conn->self_ip_string, sizeof(conn->self_ip_string)); - debug(1, "Connection %d: New connection from %s:%u to self at %s:%u.", + debug(2, "Connection %d: New connection from %s:%u to self at %s:%u.", conn->connection_number, conn->client_ip_string, conn->client_rtsp_port, conn->self_ip_string, conn->self_rtsp_port); conn->connection_start_time = get_absolute_time_in_ns();