pax_global_header 0000666 0000000 0000000 00000000064 14610511116 0014506 g ustar 00root root 0000000 0000000 52 comment=000ea4f31eb7d91029052b3c261c7acc43273031
snapcast-0.28.0/ 0000775 0000000 0000000 00000000000 14610511116 0013411 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/.clang-format 0000664 0000000 0000000 00000001017 14610511116 0015763 0 ustar 00root root 0000000 0000000 ---
AccessModifierOffset: '-4'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakTemplateDeclarations: 'true'
BreakBeforeBraces: Allman
LambdaBodyIndentation: OuterScope
ColumnLimit: '160'
IndentCaseLabels: 'true'
IndentWidth: '4'
Language: Cpp
MaxEmptyLinesToKeep: '3'
PenaltyBreakComment: '100000'
PointerAlignment: Left
Standard: Latest
UseTab: Never
...
snapcast-0.28.0/.clang-tidy 0000664 0000000 0000000 00000007137 14610511116 0015455 0 ustar 00root root 0000000 0000000 ---
# Checks: '*,clang-diagnostic-*,clang-analyzer-*'
Checks: '*,-llvmlibc-*,-readability-braces-around-statements,-hicpp-braces-around-statements,-google-readability-braces-around-statements,-hicpp-no-array-decay,-fuchsia-default-arguments-calls,-modernize-use-trailing-return-type,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-bugprone-lambda-function-name,-hicpp-signed-bitwise,-cert-err60-cpp,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-init-variables,-cppcoreguidelines-no-malloc,-hicpp-no-malloc,-google-readability-todo,-modernize-pass-by-value,-cppcoreguidelines-pro-type-member-init,-hicpp-member-init,-hicpp-avoid-c-arrays,-cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays,-abseil-string-find-startswith,-google-build-using-namespace,-cppcoreguidelines-owning-memory,-readability-else-after-return,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-readability-isolate-declaration,-cert-env33-c,-abseil-*'
# Checks: '*,clang-diagnostic-*,clang-analyzer-*'
# Checks: '*,-llvmlibc-restrict-system-libc-headers,-readability-braces-around-statements,-hicpp-braces-around-statements,-google-readability-braces-around-statements,-hicpp-no-array-decay,-fuchsia-default-arguments-calls,-modernize-use-trailing-return-type,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-bugprone-lambda-function-name,-hicpp-signed-bitwise,-cert-err60-cpp,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-init-variables,-cppcoreguidelines-no-malloc,-hicpp-no-malloc,-google-readability-todo,-modernize-pass-by-value,-cppcoreguidelines-pro-type-member-init,-hicpp-member-init,-hicpp-avoid-c-arrays,-cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays,-abseil-string-find-startswith,-google-build-using-namespace,-cppcoreguidelines-owning-memory,-readability-else-after-return,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-readability-isolate-declaration'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: johannes
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
snapcast-0.28.0/.devcontainer/ 0000775 0000000 0000000 00000000000 14610511116 0016150 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/.devcontainer/Dockerfile.alpine 0000664 0000000 0000000 00000001260 14610511116 0021410 0 ustar 00root root 0000000 0000000 # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/cpp/.devcontainer/base.Dockerfile
# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="alpine"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories
RUN apk update && apk upgrade && apk add --no-cache bash librespot git alpine-sdk gdb libvorbis-dev soxr-dev flac-dev avahi-dev expat-dev boost-dev opus-dev alsa-lib-dev ninja ccache libstdc++ clang clang-dev
snapcast-0.28.0/.devcontainer/Dockerfile.debian 0000664 0000000 0000000 00000000754 14610511116 0021371 0 ustar 00root root 0000000 0000000 ARG VARIANT="debian-11"
FROM mcr.microsoft.com/devcontainers/cpp:1-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
build-essential cmake \
libasound2-dev libpulse-dev libvorbisidec-dev libvorbis-dev libopus-dev libflac-dev \
libsoxr-dev alsa-utils libavahi-client-dev avahi-daemon libexpat1-dev libboost-dev \
cmake-format ccache
snapcast-0.28.0/.devcontainer/Dockerfile.fedora 0000664 0000000 0000000 00000000757 14610511116 0021412 0 ustar 00root root 0000000 0000000 ARG VARIANT="38"
FROM fedora:${VARIANT}
# [Optional] Uncomment this section to install additional packages.
RUN dnf -y update \
&& dnf -y install @development-tools cmake ccache \
&& dnf -y install alsa-lib-devel avahi-devel gcc-c++ libatomic libvorbis-devel opus-devel \
pulseaudio-libs-devel flac-devel soxr-devel libstdc++-static expat-devel boost-devel \
&& dnf clean all
RUN useradd -rm -d /home/vscode -s /bin/bash -g root -u 1001 vscode
USER vscode
WORKDIR /home/vscode
snapcast-0.28.0/.devcontainer/devcontainer.json 0000664 0000000 0000000 00000002016 14610511116 0021523 0 ustar 00root root 0000000 0000000 // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/cpp
{
"name": "Snapcast-dev",
"build": {
"dockerfile": "Dockerfile.debian",
// "args": { "VARIANT": "alpine" }
},
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [1704, 1705, 1780],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
snapcast-0.28.0/.github/ 0000775 0000000 0000000 00000000000 14610511116 0014751 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14610511116 0017134 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/.github/ISSUE_TEMPLATE/bug_report.md 0000664 0000000 0000000 00000001047 14610511116 0021630 0 ustar 00root root 0000000 0000000 ---
name: Bug report
about: 'Report a bug'
title: ''
labels:
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**Steps to Reproduce**
1.
2.
3.
**Environment details**
- OS: [e.g. Raspbian, debian, Windows]
- Snapcast version [e.g. 0.21.0]
- Installed from a package, self compiled, ...
**Attach logfile if applicable**
Generate logs with `snapclient --logfilter debug` or `snapserver --logging.filter debug` if possible and paste them in the following codeblock
```log
# Replace this with your logs
```
snapcast-0.28.0/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000274 14610511116 0021127 0 ustar 00root root 0000000 0000000 blank_issues_enabled: true
contact_links:
- name: Ask a question
url: https://github.com/badaix/snapcast/discussions
about: Ask questions and discuss with other community members snapcast-0.28.0/.github/ISSUE_TEMPLATE/feature_request.md 0000664 0000000 0000000 00000001153 14610511116 0022661 0 ustar 00root root 0000000 0000000 ---
name: Feature request
about: Suggest an idea or enhancement for snapcast
title: ''
labels: feature request
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
snapcast-0.28.0/.github/pull_request_template.md 0000664 0000000 0000000 00000003747 14610511116 0021725 0 ustar 00root root 0000000 0000000 [Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
* * *
## Pull Request Checklist
* Contributions must be licensed under the [GPL-3.0 License](LICENSE)
* This project loosely follows the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++17
* Code should be formatted by running `make reformat`
* Branch from the `develop` branch and ensure it is up to date with the current `develop` branch before submitting your pull request. If it doesn't merge cleanly with `develop`, you may be asked to resolve the conflicts. Pull requests to master will be closed.
* Commits should be as small as possible while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).
* Pull requests must not contain compiled sources (already set by the default .gitignore) or binary files
* Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests. If tested manually, provide information about the test scope in the PR description (e.g. “Test passed: Upgrade version from 0.42 to 0.42.23.”).
* Create _Work In Progress [WIP]_ pull requests only if you need clarification or an explicit review before you can continue your work item.
* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review by contacting us via [email](mailto:snapcast@badaix.de).
* Post review:
* If a review requires you to change your commit(s), please test the changes again.
* Amend the affected commit(s) and force push onto your branch.
* Set respective comments in your GitHub review to resolved.
* Create a general PR comment to notify the reviewers that your amendments are ready for another round of review.
snapcast-0.28.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14610511116 0017006 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/.github/workflows/ci.yml 0000664 0000000 0000000 00000020256 14610511116 0020131 0 ustar 00root root 0000000 0000000 name: CI
on:
push:
pull_request:
env:
BOOST_VERSION: 1_84_0
jobs:
static-analysis:
strategy:
fail-fast: false
matrix:
tool:
- cppcheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: print environment
run: env
- name: dependencies
run: sudo apt-get update && sudo apt-get install -yq libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libpulse-dev libavahi-client-dev avahi-daemon debhelper ccache expat cppcheck
- name: cache boost
id: cache-boost
uses: actions/cache@v4
with:
path: boost_${{ env.BOOST_VERSION }}
key: boost-${{ env.BOOST_VERSION }}
enableCrossOsArchive: true
- name: get boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2
tar xjf boost_${BOOST_VERSION}.tar.bz2
- name: configure
run: |
cmake -S . -B build \
-DWERROR=ON -DBUILD_TESTS=ON \
-DBOOST_ROOT=boost_${BOOST_VERSION} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \
-DCMAKE_CXX_FLAGS="-DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14"
- name: analysis
run: cmake --build build --target ${{ matrix.tool }}
linux:
strategy:
fail-fast: false
matrix:
compiler:
- clang-10
- clang-11
- clang-12
- clang-13
- clang-14
- clang-15
- gcc-9
- gcc-10
- gcc-11
- gcc-12
- gcc-13
include:
- compiler: clang-10
cc: clang-10
cxx: clang++-10
os: ubuntu-20.04
- compiler: clang-11
cc: clang-11
cxx: clang++-11
os: ubuntu-20.04
- compiler: clang-12
cc: clang-12
cxx: clang++-12
os: ubuntu-20.04
- compiler: clang-13
cc: clang-13
cxx: clang++-13
os: ubuntu-22.04
- compiler: clang-14
cc: clang-14
cxx: clang++-14
os: ubuntu-22.04
- compiler: clang-15
cc: clang-15
cxx: clang++-15
os: ubuntu-22.04
- compiler: gcc-9
cc: gcc-9
cxx: g++-9
os: ubuntu-22.04
- compiler: gcc-10
cc: gcc-10
cxx: g++-10
os: ubuntu-22.04
- compiler: gcc-11
cc: gcc-11
cxx: g++-11
os: ubuntu-22.04
- compiler: gcc-12
cc: gcc-12
cxx: g++-12
os: ubuntu-22.04
- compiler: gcc-13
cc: gcc-13
cxx: g++-13
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: print environment
run: env
- name: dependencies
run: sudo apt-get update && sudo apt-get install -yq libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libpulse-dev libavahi-client-dev avahi-daemon debhelper ccache expat cppcheck
- name: cache boost
id: cache-boost
uses: actions/cache@v4
with:
path: boost_${{ env.BOOST_VERSION }}
key: boost-${{ env.BOOST_VERSION }}
enableCrossOsArchive: true
- name: get boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2
tar xjf boost_${BOOST_VERSION}.tar.bz2
- name: cache ccache
id: cache-ccache
uses: actions/cache@v4
with:
# TODO: use environment variable $HOME/.ccache
path: /home/runner/.ccache
key: ${{ runner.os }}-${{ matrix.compiler }}-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-ccache-
#- name: ccache dump config
# run: ccache -p
- name: configure
run: |
cmake -S . -B build \
-DWERROR=ON -DBUILD_TESTS=ON \
-DBOOST_ROOT=boost_${BOOST_VERSION} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \
-DCMAKE_CXX_FLAGS="-DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14"
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
- name: build
env:
# TODO: use environment variable $HOME/.ccache
CCACHE_DIR: /home/runner/.ccache
run: cmake --build build --parallel 3 --verbose
macos:
strategy:
fail-fast: false
matrix:
xcode:
- "11.7"
- "12.5.1"
- "13.2.1"
- "13.3.1"
- "13.4.1"
- "14.0.1"
- "14.1"
- "14.2"
- "14.3"
- "15.0"
include:
- xcode: "11.7"
os: macos-11
- xcode: "12.5.1"
os: macos-11
- xcode: "13.2.1"
os: macos-11
- xcode: "13.3.1"
os: macos-12
- xcode: "13.4.1"
os: macos-12
- xcode: "14.0.1"
os: macos-12
- xcode: "14.1"
os: macos-12
- xcode: "14.2"
os: macos-12
- xcode: "14.3"
os: macos-13
- xcode: "15.0"
os: macos-13
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: print environment
run: env
- name: dependencies
run: brew install pkgconfig libsoxr ccache expat
- name: cache boost
id: cache-boost
uses: actions/cache@v4
with:
path: boost_${{ env.BOOST_VERSION }}
key: boost-${{ env.BOOST_VERSION }}
enableCrossOsArchive: true
- name: get boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2
tar xjf boost_${BOOST_VERSION}.tar.bz2
- name: cache ccache
id: cache-ccache
uses: actions/cache@v4
with:
path: /Users/runner/Library/Caches/ccache
key: ${{ runner.os }}-${{ matrix.xcode }}-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.xcode }}-ccache-
- name: configure
run: |
cmake -S . -B build \
-DWERROR=ON -DBUILD_TESTS=ON \
-DBOOST_ROOT=boost_${BOOST_VERSION} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_FLAGS="-I/usr/local/include -DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14"
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
- name: build
run: cmake --build build --parallel 3 --verbose
windows:
strategy:
fail-fast: false
matrix:
compiler:
- vs-16
- vs-17
include:
- compiler: vs-16
os: windows-2019
vs: "Visual Studio 16 2019"
- compiler: vs-17
os: windows-2022
vs: "Visual Studio 17 2022"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: cache dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
#path: ${VCPKG_INSTALLATION_ROOT}\installed
path: c:\vcpkg\installed
key: ${{ runner.os }}-dependencies
- name: dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: vcpkg.exe install libflac libvorbis soxr opus boost-asio --triplet x64-windows
- name: configure
run: |
echo vcpkg installation root: ${env:VCPKG_INSTALLATION_ROOT}
cmake -S . -B build -G "${{ matrix.vs }}" `
-DWERROR=ON -DBUILD_TESTS=ON `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET="x64-windows" `
-DCMAKE_BUILD_TYPE=Release `
-DREVISION="${{ github.sha }}"
- name: build
run: cmake --build build --config Release --parallel 3 --verbose
snapcast-0.28.0/.github/workflows/package.yml 0000664 0000000 0000000 00000022564 14610511116 0021135 0 ustar 00root root 0000000 0000000 name: Package
run-name: Package ${{ github.sha }} by @${{ github.actor }}
on:
workflow_dispatch:
env:
BOOST_VERSION: 1_84_0
SNAPWEB_VERSION: v0.7.0
jobs:
deb:
strategy:
fail-fast: false
matrix:
debian:
- bullseye
- bookworm
arch:
- amd64
- armhf
- arm64
include:
- arch: "amd64"
os: ubuntu-latest
image_prefix: "debian:"
- arch: "armhf"
os: self-hosted-rpi4
image_prefix: "badaix/raspios-lite:"
- arch: "arm64"
os: self-hosted-rpi5
image_prefix: "badaix/raspios-lite:"
runs-on: ${{ matrix.os }}
name: deb (${{ matrix.arch }}, ${{ matrix.debian }})
timeout-minutes: 240
container:
image: ${{matrix.image_prefix}}${{matrix.debian}}
steps:
- name: Get dependencies
run: apt-get update && apt-get install -yq wget debhelper build-essential cmake git rename libatomic1 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libpulse-dev libavahi-client-dev avahi-daemon libexpat1-dev python3 ccache unzip
env:
DEBIAN_FRONTEND: noninteractive
- name: Checkout
uses: actions/checkout@v4
- name: Setup environment
run: |
echo "PARENT_DIR=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
BOOST_DOT_VERSION=$(echo ${BOOST_VERSION} | sed 's/_/./g')
echo "BOOST_DOT_VERSION=$BOOST_DOT_VERSION" >> $GITHUB_ENV
echo "BOOST=boost_${BOOST_VERSION}" >> $GITHUB_ENV
ln -s extras/package/debian debian
- name: Create changelog
run: |
$GITHUB_WORKSPACE/debian/changelog_md2deb.py $GITHUB_WORKSPACE/changelog.md > $GITHUB_WORKSPACE/debian/changelog
cat $GITHUB_WORKSPACE/debian/changelog
- name: Clean up
run: rm -rf ${{env.PARENT_DIR}}/snap*_${{ matrix.arch }}.deb
- name: Cache boost
id: cache-boost
uses: actions/cache@v4
with:
path: ${{env.BOOST}}
key: ${{env.BOOST}}
- name: Get boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/${{env.BOOST_DOT_VERSION}}/source/${{env.BOOST}}.tar.bz2
tar xjf ${{env.BOOST}}.tar.bz2
- name: cache ccache
id: cache-ccache
uses: actions/cache@v4
with:
# TODO: use environment variable $HOME/.ccache
path: /home/runner/.ccache
key: ${{ matrix.os }}-${{ matrix.debian }}-ccache-${{ github.sha }}
restore-keys: ${{ matrix.os }}-${{ matrix.debian }}-ccache-
- name: Get Snapweb
run: |
wget https://github.com/badaix/snapweb/releases/download/${SNAPWEB_VERSION}/snapweb.zip
unzip snapweb.zip -d snapweb
- name: Create deb package
env:
# TODO: use environment variable $HOME/.ccache
CCACHE_DIR: /home/runner/.ccache
run: |
fakeroot make -f debian/rules CMAKEFLAGS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBOOST_ROOT=$GITHUB_WORKSPACE/${{env.BOOST}} -DCMAKE_BUILD_TYPE:STRING=Release -DREVISION=${{ github.sha }} -DBUILD_WITH_PULSE=OFF -DSNAPWEB_DIR:STRING=$GITHUB_WORKSPACE/snapweb" binary
rename 's/_${{ matrix.arch }}/_without-pulse_${{ matrix.arch }}/g' ../snapclient*_${{ matrix.arch }}.deb
fakeroot make -f debian/rules clean
fakeroot make -f debian/rules CMAKEFLAGS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBOOST_ROOT=$GITHUB_WORKSPACE/${{env.BOOST}} -DCMAKE_BUILD_TYPE:STRING=Release -DREVISION=${{ github.sha }} -DSNAPWEB_DIR:STRING=$GITHUB_WORKSPACE/snapweb" binary
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: snapcast_${{ matrix.arch }}-debian-${{matrix.debian}}-${{ github.sha }}
path: ${{env.PARENT_DIR}}/snap*_${{ matrix.arch }}.deb
# mac:
# strategy:
# fail-fast: false
# matrix:
# xcode: ['11']
# runs-on: macos-latest
# name: mac (xcode ${{ matrix.xcode }})
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Checkout Snapcast
# uses: actions/checkout@v4
# with:
# repository: badaix/snapcast
# path: src/snapcast
# ref: ${{ env.VERSION }}
# - name: Setup environment
# run: |
# BOOST_DOT_VERSION=$(echo ${BOOST_VERSION} | sed 's/_/./g')
# echo "BOOST_DOT_VERSION=$BOOST_DOT_VERSION" >> $GITHUB_ENV
# echo "BOOST=boost_${BOOST_VERSION}" >> $GITHUB_ENV
# - name: Get dependencies
# run: brew install pkgconfig libsoxr ccache expat
# - name: Cache boost
# id: cache-boost
# uses: actions/cache@v4
# with:
# path: ${{env.BOOST}}
# key: ${{ runner.os }}-boost
# - name: Get boost
# if: steps.cache-boost.outputs.cache-hit != 'true'
# run: |
# wget https://boostorg.jfrog.io/artifactory/main/release/${{env.BOOST_DOT_VERSION}}/source/${{env.BOOST}}.tar.bz2
# tar xjf ${{env.BOOST}}.tar.bz2
# - name: Cache ccache
# id: cache-ccache
# uses: actions/cache@v4
# with:
# path: /Users/runner/.ccache
# key: ${{ runner.os }}-ccache-${{ github.sha }}
# restore-keys: ${{ runner.os }}-ccache-
# #- name: ccache dump config
# # run: ccache -p
# - name: configure
# run: cmake -S $GITHUB_WORKSPACE/src/snapcast -B build -DBOOST_ROOT=$GITHUB_WORKSPACE/${{env.BOOST}} -DCMAKE_BUILD_TYPE=Release -DREVISION=${{ github.sha }} -DWERROR=ON -DBUILD_TESTS=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS="-I/usr/local/include -Wno-deprecated-declarations"
# - name: build
# run: cmake --build build --parallel 3
# rpm:
# if: ${{ false }} # disable for now
# strategy:
# fail-fast: false
# matrix:
# image:
# - 34
# - 35
# os:
# - ubuntu-latest
# - self-hosted-rpi4
# include:
# - os: ubuntu-latest
# arch: "x86_64"
# - os: self-hosted-rpi4
# arch: "armv7hl"
# runs-on: ${{ matrix.os }}
# name: rpm (${{ matrix.arch }}, fedora ${{ matrix.image }})
# container:
# image: fedora:${{matrix.image}}
# steps:
# - name: Get dependencies
# run: dnf -y update && dnf -y install wget git rpm-build gcc-c++ cmake boost-devel alsa-lib-devel avahi-devel libatomic libvorbis-devel opus-devel pulseaudio-libs-devel flac-devel soxr-devel libstdc++-static expat-devel
# - name: Checkout
# uses: actions/checkout@v4
# - name: Checkout Snapcast
# uses: actions/checkout@v4
# with:
# repository: badaix/snapcast
# path: src/snapcast
# ref: ${{ env.VERSION }}
# - name: Create rpm package
# run: |
# mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# cp rpm/* ~/rpmbuild/SOURCES/
# tar -C $GITHUB_WORKSPACE/src/ -czvf ~/rpmbuild/SOURCES/snapcast.tar.gz snapcast
# rpmbuild --nodebuginfo --define '_reversion ${{ github.sha }}' --define '_version ${{ env.VERSION }}' -bb ~/rpmbuild/SOURCES/snapcast.spec
# - name: Archive artifacts
# uses: actions/upload-artifact@v4
# with:
# name: snapcast_${{ matrix.arch }}-fedora-${{matrix.image}}-${{ github.sha }}
# path: ~/rpmbuild/RPMS/${{ matrix.arch }}/snap*.rpm
win:
runs-on: windows-2019
name: win
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Snapcast
uses: actions/checkout@v4
with:
repository: badaix/snapcast
path: src/snapcast
ref: ${{ env.VERSION }}
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
#path: ${VCPKG_INSTALLATION_ROOT}\installed
path: c:\vcpkg\installed
key: ${{ runner.os }}-dependencies
- name: Get dependenciesenv
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: vcpkg.exe install libflac libvorbis soxr opus boost-asio --triplet x64-windows
- name: configure
run: |
echo vcpkg installation root: $env:VCPKG_INSTALLATION_ROOT
cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows" -DCMAKE_BUILD_TYPE="Release" -DREVISION="${{ github.sha }}" -DWERROR=ON -DBUILD_TESTS=ON
- name: build
run: cmake --build build --config Release --parallel 3 --verbose
- name: installer
run: |
copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\FLAC.dll bin\Release\
copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\ogg.dll bin\Release\
copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\opus.dll bin\Release\
copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\vorbis.dll bin\Release\
copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\soxr.dll bin\Release\
copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\v142\vc_redist.x64.exe" bin\Release\
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: snapcast_win64-${{ github.sha }}
path: |
bin\Release\snapclient.exe
bin\Release\FLAC.dll
bin\Release\ogg.dll
bin\Release\opus.dll
bin\Release\vorbis.dll
bin\Release\soxr.dll
bin\Release\vc_redist.x64.exe
snapcast-0.28.0/.gitignore 0000664 0000000 0000000 00000001726 14610511116 0015407 0 ustar 00root root 0000000 0000000 # Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.*~
client/snapclient
server/snapserver
.vscode
GPATH
GRTAGS
GTAGS
build
bin
android/.idea
android/Snapcast/release
# debian packages
debian/.debhelper
debian/snapclient
debian/snapserver
debian/debhelper-build-stamp
debian/snapclient.debhelper.log
debian/snapserver.debhelper.log
debian/files
debian/snapclient.postinst.debhelper
debian/snapclient.postrm.debhelper
debian/snapclient.prerm.debhelper
debian/snapclient.substvars
debian/snapserver.postinst.debhelper
debian/snapserver.postrm.debhelper
debian/snapserver.prerm.debhelper
debian/snapserver.substvars
debian/tmp
obj-x86_64-linux-gnu
# clangd
.cache
compile_commands.json
# misc
notes.txt
sanitizer-suppressions.txt
snapserver.conf
extras/package/debian/snap*.debhelper.log
snapcast-0.28.0/CMakeLists.txt 0000664 0000000 0000000 00000023651 14610511116 0016160 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.5)
project(
snapcast
LANGUAGES CXX
VERSION 0.28.0)
set(PROJECT_DESCRIPTION "Multiroom client-server audio player")
set(PROJECT_URL "https://github.com/badaix/snapcast")
option(BUILD_SHARED_LIBS "Build snapcast in a shared context" ON)
option(BUILD_STATIC_LIBS "Build snapcast in a static context" ON)
option(BUILD_TESTS "Build tests (in test/snapcast_test)" OFF)
option(WERROR "Treat warnings as errors" OFF)
option(ASAN "Enable AddressSanitizer" OFF)
option(TSAN "Enable ThreadSanitizer" OFF)
option(UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
option(TIDY "Enable clang tidy" OFF)
if(REVISION)
add_compile_definitions(REVISION=\"${REVISION}\")
endif()
if(TIDY)
find_program(CLANG_TIDY "clang-tidy")
if(CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(FREEBSD TRUE)
if(BUILD_CLIENT)
message(
FATAL_ERROR
"Snapclient not yet supported for FreeBSD, use \"-DBUILD_CLIENT=OFF\"")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(ANDROID TRUE)
endif()
if(MSVC)
# warning level 4 and all warnings as errors warning C4505: 'getArch':
# unreferenced local function has been removed warning C4458: declaration of
# 'size' hides class member warning C4459: declaration of 'query' hides global
# declaration
add_compile_options(/W4 /wd4458 /wd4459 /wd4505)
if(WERROR)
add_compile_options(/WX)
endif()
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-function)
if(MACOSX)
add_compile_options(-Wno-deprecated-declarations)
endif()
if(WERROR)
add_compile_options(-Werror)
endif()
if(ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
if(TSAN)
add_compile_options(-fsanitize=thread)
add_link_options(-fsanitize=thread)
endif()
if(UBSAN)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
endif()
include(GNUInstallDirs)
include(${CMAKE_SOURCE_DIR}/cmake/cppcheck.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/reformat.cmake)
if(NOT WIN32)
option(BUILD_SERVER "Build Snapserver" ON) # no Windows server for now
endif()
option(BUILD_CLIENT "Build Snapclient" ON)
option(BUILD_WITH_FLAC "Build with FLAC support" ON)
option(BUILD_WITH_VORBIS "Build with VORBIS support" ON)
option(BUILD_WITH_TREMOR "Build with vorbis using TREMOR" ON)
option(BUILD_WITH_OPUS "Build with OPUS support" ON)
option(BUILD_WITH_AVAHI "Build with AVAHI support" ON)
option(BUILD_WITH_EXPAT "Build with EXPAT support" ON)
option(BUILD_WITH_PULSE "Build with PulseAudio support" ON)
if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
message(
FATAL_ERROR
"One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON to build"
)
endif()
if(NOT BUILD_CLIENT AND NOT BUILD_SERVER)
message(
FATAL_ERROR
"One or both of BUILD_CLIENT or BUILD_SERVER must be set to ON to build")
endif()
# Configure paths
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR
bin
CACHE PATH "Output directory for binary files")
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR
lib
CACHE PATH "Output directory for libraries")
endif()
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
set(CMAKE_INSTALL_INCLUDEDIR
include
CACHE PATH "Output directory for header files")
endif()
set(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}" "${CMAKE_INSTALL_INCLUDEDIR}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
add_compile_definitions(VERSION="${PROJECT_VERSION}")
if(NOT ANDROID)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
endif()
# Configure compiler options
set(CMAKE_CXX_STANDARD 17)
include(${CMAKE_SOURCE_DIR}/cmake/TargetArch.cmake)
target_architecture(HOST_ARCH)
# message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Architecture: ${HOST_ARCH}")
# message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
if(ARCH)
message(STATUS "Using arch: ${ARCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${ARCH}")
endif()
include(CheckAtomic)
include(TestBigEndian)
test_big_endian(BIGENDIAN)
if(${BIGENDIAN})
add_compile_definitions(IS_BIG_ENDIAN)
endif(${BIGENDIAN})
# Check dependencies
if(NOT WIN32) # no PkgConfig on Windows...
find_package(PkgConfig REQUIRED)
endif()
find_package(Threads REQUIRED)
include(CMakePushCheckState)
include(CheckIncludeFileCXX)
include_directories(${INCLUDE_DIRS})
include(${CMAKE_SOURCE_DIR}/cmake/CheckCXX11StringSupport.cmake)
check_cxx11_string_support(HAS_CXX11_STRING_SUPPORT)
if(NOT HAS_CXX11_STRING_SUPPORT)
add_compile_definitions(NO_CPP11_STRING)
endif()
if(NOT WIN32 AND NOT ANDROID)
if(MACOSX)
set(BONJOUR_FOUND true)
if(BONJOUR_FOUND)
add_compile_definitions(HAS_BONJOUR)
endif(BONJOUR_FOUND)
add_compile_definitions(FREEBSD MACOS HAS_DAEMON)
link_directories("/usr/local/lib")
list(APPEND INCLUDE_DIRS "/usr/local/include")
else()
pkg_search_module(ALSA REQUIRED alsa)
if(ALSA_FOUND)
add_compile_definitions(HAS_ALSA)
endif(ALSA_FOUND)
if(BUILD_WITH_PULSE)
pkg_search_module(PULSE libpulse)
if(PULSE_FOUND)
add_compile_definitions(HAS_PULSE)
endif(PULSE_FOUND)
endif(BUILD_WITH_PULSE)
if(BUILD_WITH_AVAHI)
pkg_search_module(AVAHI avahi-client)
if(AVAHI_FOUND)
add_compile_definitions(HAS_AVAHI)
else()
message(STATUS "avahi-client not found")
endif(AVAHI_FOUND)
endif(BUILD_WITH_AVAHI)
add_compile_definitions(HAS_DAEMON)
if(FREEBSD)
add_compile_definitions(FREEBSD)
link_directories("/usr/local/lib")
list(APPEND INCLUDE_DIRS "/usr/local/include")
endif()
endif()
pkg_search_module(SOXR soxr)
if(SOXR_FOUND)
add_compile_definitions(HAS_SOXR)
else()
message(STATUS "soxr not found")
endif(SOXR_FOUND)
if(BUILD_WITH_FLAC)
pkg_search_module(FLAC flac)
if(FLAC_FOUND)
add_compile_definitions(HAS_FLAC)
else()
message(STATUS "flac not found")
endif(FLAC_FOUND)
endif()
if(BUILD_WITH_VORBIS OR BUILD_WITH_TREMOR)
pkg_search_module(OGG ogg)
if(OGG_FOUND)
add_compile_definitions(HAS_OGG)
else()
message(STATUS "ogg not found")
endif(OGG_FOUND)
endif()
if(BUILD_WITH_VORBIS)
pkg_search_module(VORBIS vorbis)
if(VORBIS_FOUND)
add_compile_definitions(HAS_VORBIS)
endif(VORBIS_FOUND)
endif()
if(BUILD_WITH_TREMOR)
pkg_search_module(TREMOR vorbisidec)
if(TREMOR_FOUND)
add_compile_definitions(HAS_TREMOR)
endif(TREMOR_FOUND)
endif()
if((BUILD_WITH_VORBIS OR BUILD_WITH_TREMOR)
AND NOT VORBIS_FOUND
AND NOT TREMOR_FOUND)
message(STATUS "tremor and vorbis not found")
endif()
if(BUILD_WITH_VORBIS)
pkg_search_module(VORBISENC vorbisenc)
if(VORBISENC_FOUND)
add_compile_definitions(HAS_VORBIS_ENC)
else()
message(STATUS "vorbisenc not found")
endif(VORBISENC_FOUND)
endif()
if(BUILD_WITH_OPUS)
pkg_search_module(OPUS opus)
if(OPUS_FOUND)
add_compile_definitions(HAS_OPUS)
else()
message(STATUS "opus not found")
endif(OPUS_FOUND)
endif()
if(BUILD_WITH_EXPAT)
pkg_search_module(EXPAT expat)
if(EXPAT_FOUND)
add_compile_definitions(HAS_EXPAT)
else()
message(STATUS "expat not found")
endif(EXPAT_FOUND)
endif()
endif()
if(NOT ANDROID)
find_package(Boost 1.74 REQUIRED)
else()
find_package(oboe REQUIRED CONFIG)
find_package(flac REQUIRED CONFIG)
find_package(ogg REQUIRED CONFIG)
find_package(opus REQUIRED CONFIG)
find_package(soxr REQUIRED CONFIG)
find_package(tremor REQUIRED CONFIG)
find_package(boost REQUIRED CONFIG)
add_compile_definitions(HAS_OBOE)
add_compile_definitions(HAS_OPENSL)
add_compile_definitions(HAS_FLAC)
add_compile_definitions(HAS_OGG)
add_compile_definitions(HAS_OPUS)
add_compile_definitions(HAS_SOXR)
add_compile_definitions(HAS_TREMOR)
endif()
add_compile_definitions(BOOST_ERROR_CODE_HEADER_ONLY BOOST_ASIO_NO_TS_EXECUTORS)
if(WIN32)
include(FindPackageHandleStandardArgs)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
find_path(FLAC_INCLUDE_DIRS FLAC/all.h)
find_library(FLAC_LIBRARIES FLAC)
find_package_handle_standard_args(FLAC REQUIRED FLAC_INCLUDE_DIRS
FLAC_LIBRARIES)
find_path(OGG_INCLUDE_DIRS ogg/ogg.h)
find_library(OGG_LIBRARIES ogg)
find_package_handle_standard_args(Ogg REQUIRED OGG_INCLUDE_DIRS OGG_LIBRARIES)
find_path(VORBIS_INCLUDE_DIRS vorbis/vorbisenc.h)
find_library(VORBIS_LIBRARIES vorbis)
find_package_handle_standard_args(Vorbis REQUIRED VORBIS_INCLUDE_DIRS
VORBIS_LIBRARIES)
find_path(OPUS_INCLUDE_DIRS opus/opus.h)
find_library(OPUS_LIBRARIES opus)
find_package_handle_standard_args(Opus REQUIRED OPUS_INCLUDE_DIRS
OPUS_LIBRARIES)
find_path(SOXR_INCLUDE_DIRS soxr.h)
find_library(SOXR_LIBRARIES soxr)
find_package_handle_standard_args(Soxr REQUIRED SOXR_INCLUDE_DIRS
SOXR_LIBRARIES)
add_compile_definitions(
NTDDI_VERSION=0x06020000
_WIN32_WINNT=0x0602
WINVER=0x0602
WINDOWS
WIN32_LEAN_AND_MEAN
UNICODE
_UNICODE
_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(
HAS_OGG
HAS_VORBIS
HAS_FLAC
HAS_VORBIS_ENC
HAS_OPUS
HAS_WASAPI
HAS_SOXR)
endif()
list(APPEND CMAKE_REQUIRED_INCLUDES "${INCLUDE_DIRS}")
# include(${CMAKE_SOURCE_DIR}/cmake/SystemdService.cmake)
add_subdirectory(common)
if(BUILD_SERVER)
add_subdirectory(server)
endif()
if(BUILD_CLIENT)
add_subdirectory(client)
endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif(BUILD_TESTS)
snapcast-0.28.0/CMakePresets.json 0000664 0000000 0000000 00000011207 14610511116 0016633 0 ustar 00root root 0000000 0000000 {
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja",
"hidden": true,
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux",
"displayName": "Linux",
"inherits": "default",
"condition": {
"lhs": "${hostSystemName}",
"type": "equals",
"rhs": "Linux"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "windows",
"inherits": "default",
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"condition": {
"lhs": "${hostSystemName}",
"type": "equals",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Windows"
]
}
}
},
{
"name": "macos",
"displayName": "macOS",
"inherits": "default",
"condition": {
"lhs": "${hostSystemName}",
"type": "equals",
"rhs": "Darwin"
}
},
{
"name": "android",
"inherits": "default",
"hidden": true,
"condition": {
"lhs": "$env{ANDROID_NDK_HOME}",
"type": "notEquals",
"rhs": ""
},
"toolchainFile": "$env{VCPKG_HOME}/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "Android",
"CMAKE_ANDROID_NDK": "$env{ANDROID_NDK_HOME}",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "$env{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake"
}
},
{
"name": "android-x86",
"displayName": "Android x86",
"inherits": "android",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "x86",
"VCPKG_TARGET_TRIPLET": "x86-android"
}
},
{
"name": "android-x86_64",
"displayName": "Android x86_64",
"inherits": "android",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "x86_64",
"VCPKG_TARGET_TRIPLET": "x64-android"
}
},
{
"name": "android-armeabi-v7a",
"displayName": "Android armeabi-v7a",
"inherits": "android",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a",
"VCPKG_TARGET_TRIPLET": "arm-android"
}
},
{
"name": "android-arm64-v8a",
"displayName": "Android arm64-v8a",
"inherits": "android",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "arm64-v8a",
"VCPKG_TARGET_TRIPLET": "arm64-android"
}
}
],
"buildPresets": [
{
"name": "linux",
"configurePreset": "linux",
"displayName": "Linux"
},
{
"name": "windows",
"configurePreset": "windows",
"displayName": "x64"
},
{
"name": "macos",
"configurePreset": "macos",
"displayName": "macOS"
},
{
"name": "android-x86",
"configurePreset": "android-x86",
"displayName": "x86"
},
{
"name": "android-x86_64",
"configurePreset": "android-x86_64",
"displayName": "x86_64"
},
{
"name": "android-armeabi-v7a",
"configurePreset": "android-armeabi-v7a",
"displayName": "armeabi-v7a"
},
{
"name": "android-arm64-v8a",
"configurePreset": "android-arm64-v8a",
"displayName": "arm64-v8a"
}
]
}
snapcast-0.28.0/CONTRIBUTING.md 0000664 0000000 0000000 00000011162 14610511116 0015643 0 ustar 00root root 0000000 0000000 # Contributing
## Engaging in Our Project
You can contribute in several ways:
* Contribute code for new features, bugfixes, or documentation (see below)
* Help testing the latest features. Nightly builds are available in [Actions](https://github.com/badaix/snapcast/actions)
* Star the project
* Donate on [PayPal](https://www.paypal.me/badaix)
* Spread the word: blog about Snapcast, tell your friends ...
We use GitHub to manage reviews of pull requests.
* If you are a new contributor, see: [Steps to Contribute](#steps-to-contribute)
* Before implementing your change, create an issue that describes the problem you would like to solve or the code that should be enhanced. Please note that you are willing to work on that issue.
* The team will review the issue and decide whether it should be implemented as a Pull Request. In that case, they will assign the issue to you. If the team decides against picking up the issue, it will be closed with a proper explanation.
## Steps to Contribute
Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on. This is to prevent duplicated efforts from other contributors on the same issue.
Only start working on the Pull Request after the team assigned the issue to you to avoid unnecessary efforts.
If you have questions about one of the issues, please comment on them, and one of the maintainers will clarify.
We kindly ask you to follow the [Pull Request Checklist](#Pull-Request-Checklist) to ensure reviews can happen accordingly.
## Contributing Code
You are welcome to contribute code in order to fix a bug or to implement a new feature that is logged as an issue.
Only start working on the Pull Request after the team assigned the issue to you to avoid unnecessary efforts.
Please note that Snapweb related contributions should be made in the [Snapweb project](https://github.com/badaix/snapweb).
The following rule governs code contributions:
* Contributions must be licensed under the [GPL-3.0 License](LICENSE)
* This project loosely follows the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
* For better compatibility with embedded toolchains, the used C++ standard should be limited to C++17
* Code should be formatted by running `make reformat`
## Contributing Documentation
You are welcome to contribute documentation to the project.
The following rule governs documentation contributions:
* Contributions must be licensed under the same license as code, the [GPL-3.0 License](LICENSE)
## Pull Request Checklist
* Branch from the `develop` branch and ensure it is up to date with the current `develop` branch before submitting your pull request. If it doesn't merge cleanly with `develop`, you may be asked to resolve the conflicts. Pull requests to master will be closed.
* Commits should be as small as possible while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).
* Pull requests must not contain compiled sources (already set by the default .gitignore) or binary files
* Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests. If tested manually, provide information about the test scope in the PR description (e.g. “Test passed: Upgrade version from 0.42 to 0.42.23.”).
* Create _Work In Progress [WIP]_ pull requests only if you need clarification or an explicit review before you can continue your work item.
* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review by contacting us via [email](mailto:snapcast@badaix.de).
* Post review:
* If a review requires you to change your commit(s), please test the changes again.
* Amend the affected commit(s) and force push onto your branch.
* Set respective comments in your GitHub review to resolved.
* Create a general PR comment to notify the reviewers that your amendments are ready for another round of review.
## Issues and Planning
* We use GitHub issues to track bugs and enhancement requests.
* Please provide as much context as possible when you open an issue. The information you provide must be comprehensive enough to reproduce that issue for the assignee.
* Attach a log file (preferably inline as code block) if necessary. Use `debug` log level (`snapclient --logfilter debug`, `snapserver --logging.filter debug`).
* Please apply one or more applicable [labels](https://github.com/badaix/snapcast/labels) to your issue so that all community members are able to cluster the issues better.
snapcast-0.28.0/LICENSE 0000664 0000000 0000000 00000104506 14610511116 0014424 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
snapcast-0.28.0/README.md 0000664 0000000 0000000 00000031562 14610511116 0014677 0 ustar 00root root 0000000 0000000 # Snapcast


**S**y**n**chronous **a**udio **p**layer
[](https://github.com/badaix/snapcast/actions/workflows/ci.yml)
[](https://github.com/badaix/snapcast/releases)
[](https://github.com/badaix/snapcast/releases)
[](https://www.paypal.me/badaix)
Snapcast is a multiroom client-server audio player, where all clients are time synchronized with the server to play perfectly synced audio. It's not a standalone player, but an extension that turns your existing audio player into a Sonos-like multiroom solution.
Audio is captured by the server and routed to the connected clients. Several players can feed audio to the server in parallel and clients can be grouped to play the same audio stream.
One of the most generic ways to use Snapcast is in conjunction with the music player daemon ([MPD](http://www.musicpd.org/)) or [Mopidy](https://www.mopidy.com/).

## How does it work
The Snapserver reads PCM chunks from configurable stream sources:
- **Named pipe**, e.g. `/tmp/snapfifo`
- **ALSA** to capture line-in, microphone, alsa-loop (to capture audio from other players)
- **TCP**
- **stdout** of a process
- Many more
The chunks are encoded and tagged with the local time. Supported codecs are:
- **PCM** lossless uncompressed
- **FLAC** lossless compressed [default]
- **Vorbis** lossy compression
- **Opus** lossy low-latency compression
The encoded chunks are sent via a TCP connection to the Snapclients.
Each client does continuous time synchronization with the server, so that the client is always aware of the local server time.
Every received chunk is first decoded and added to the client's chunk-buffer. Knowing the server's time, the chunk is played out using a system dependend low level audio API (e.g. ALSA) at the appropriate time. Time deviations are corrected by playing faster/slower, which is done by removing/duplicating single samples (a sample at 48kHz has a duration of ~0.02ms).
Typically the deviation is below 0.2ms.
For more information on the binary protocol, please see the [documentation](doc/binary_protocol.md).
## Installation
You can either install Snapcast from a prebuilt package (recommended for new users), or build and install snapcast from source.
### Install Linux packages (recommended for beginners)
Snapcast packages are available for several Linux distributions:
- [Debian](doc/install.md#debian)
- [OpenWrt](doc/install.md#openwrt)
- [Alpine Linux](doc/install.md#alpine-linux)
- [Archlinux](doc/install.md#archlinux)
- [Void Linux](doc/install.md#void-linux)
### Nightly builds
There are debian packages of automated builds for `armhf`, `arm64` and `amd64` in [Snapcast Actions - Package workflow](https://github.com/badaix/snapcast/actions/workflows/package.yml).
Download and extract the archive for your architecture and follow the [debian installation instructions](doc/install.md#debian).
### Install using Homebrew
On macOS and Linux, snapcast can be installed using [Homebrew](https://brew.sh):
```bash
brew install snapcast
```
### Installation from source
Please follow this [guide](doc/build.md) to build Snapcast for
- [Linux](doc/build.md#linux-native)
- [FreeBSD](doc/build.md#freebsd-native)
- [macOS](doc/build.md#macos-native)
- [Android](doc/build.md#android-cross-compile)
- [OpenWrt](doc/build.md#openwrtlede-cross-compile)
- [Buildroot](doc/build.md#buildroot-cross-compile)
- [Raspberry Pi](doc/build.md#raspberry-pi-cross-compile)
- [Windows](doc/build.md#windows-vcpkg)
## Configuration
After installation, Snapserver and Snapclient are started with the command line arguments that are configured in `/etc/default/snapserver` and `/etc/default/snapclient`.
Allowed options are listed in the man pages (`man snapserver`, `man snapclient`) or by invoking the snapserver or snapclient with the `-h` option.
### Server
The server configuration is done in `/etc/snapserver.conf`. Different audio sources can by configured in the `[stream]` section with a list of `source` options, e.g.:
```ini
[stream]
source = pipe:///tmp/snapfifo?name=Radio&sampleformat=48000:16:2&codec=flac
source = file:///home/user/Musik/Some%20wave%20file.wav?name=File
```
Available stream sources are:
- [pipe](doc/configuration.md#pipe): read audio from a named pipe
- [alsa](doc/configuration.md#alsa): read audio from an alsa device
- [librespot](doc/configuration.md#librespot): launches librespot and reads audio from stdout
- [airplay](doc/configuration.md#airplay): launches airplay and read audio from stdout
- [file](doc/configuration.md#file): read PCM audio from a file
- [process](doc/configuration.md#process): launches a process and reads audio from stdout
- [tcp](doc/configuration.md#tcp-server): receives audio from a TCP socket, can act as client or server
- [meta](doc/configuration.md#meta): read and mix audio from other stream sources
### Client
The client will use as audio backend the system's low level audio API to have the best possible control and most precise timing to achieve perfectly synced playback.
Available audio backends are configured using the `--player` command line parameter:
| Backend | OS | Description | Parameters |
| --------- | ------- | ------------ | ---------- |
| alsa | Linux | ALSA | `buffer_time=` (default 80, min 10) `fragments=` (default 4, min 2) |
| pulse | Linux | PulseAudio | `buffer_time=` (default 100, min 10) `server=` - default not-set: use the default server `property==` set PA property, can be used multiple times (default `media.role=music`) |
| oboe | Android | Oboe, using OpenSL ES on Android 4.1 and AAudio on 8.1 | |
| opensl | Android | OpenSL ES | |
| coreaudio | macOS | Core Audio | |
| wasapi | Windows | Windows Audio Session API | |
| file | All | Write audio to file | `filename=` (`` = `stdout`, `stderr`, `null` or a filename) `mode=[w|a]` (`w`: write (discarding the content), `a`: append (keeping the content) |
Parameters are appended to the player name, e.g. `--player alsa:buffer_time=100`. Use `--player :?` to get a list of available options.
For some audio backends you can configure the PCM device using the `-s` or `--soundcard` parameter, the device is chosen by index or name. Available PCM devices can be listed with `-l` or `--list`
If you are running MPD and Shairport-sync into a soundcard that only supports 48000 sample rate, you can use `--sampleformat ` and the snapclient will resample the audio from shairport-sync, for example, which is 44100 (i.e. `--sampleformat 48000:16:*`)
## Test
You can test your installation by copying random data into the server's fifo file
cat /dev/urandom > /tmp/snapfifo
All connected clients should play random noise now. You might raise the client's volume with "alsamixer".
It's also possible to let the server play a WAV file. Simply configure a `file` stream in `/etc/snapserver.conf`, and restart the server:
[stream]
source = file:///home/user/Musik/Some%20wave%20file.wav?name=test
When you are using a Raspberry Pi, you might have to change your audio output to the 3.5mm jack:
#The last number is the audio output with 1 being the 3.5 jack, 2 being HDMI and 0 being auto.
amixer cset numid=3 1
To setup WiFi on a Raspberry Pi, you can follow this [guide](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
## Control
Snapcast can be controlled using a [JSON-RPC API](doc/json_rpc_api/control.md) over plain TCP, HTTP, or Websockets:
- Set client's volume
- Mute clients
- Rename clients
- Assign a client to a stream
- Manage groups
- ...
### WebApp
The server is shipped with [Snapweb](https://github.com/badaix/snapweb), this WebApp can be reached under `http://:1780`.


### Android client
There is an Android client [snapdroid](https://github.com/badaix/snapdroid) available in [Releases](https://github.com/badaix/snapdroid/releases/latest) and on [Google Play](https://play.google.com/store/apps/details?id=de.badaix.snapcast)

### Contributions
There is also an unofficial WebApp from @atoomic [atoomic/snapcast-volume-ui](https://github.com/atoomic/snapcast-volume-ui).
This app lists all clients connected to a server and allows you to control individually 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 into 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 and a [snapcast python plugin for Domoticz](https://github.com/akamming/domoticz-snapcast) to integrate a Snapcast controller into the [Domoticz](https://domoticz.com/) home automation system.
For a web interface in Python, see [snapcastr](https://github.com/xkonni/snapcastr), based on [python-snapcast](https://github.com/happyleavesaoc/python-snapcast). This interface controls client volume and assigns streams to groups.
Another web interface running on any device is [snapcast-websockets-ui](https://github.com/derglaus/snapcast-websockets-ui), running entirely in the browser, which needs [websockify](https://github.com/novnc/websockify). No configuration needed; features almost all functions; still needs some tuning for the optics.
A web interface called [HydraPlay](https://github.com/mariolukas/HydraPlay) integrates Snapcast and multiple Mopidy instances. It is JavaScript based and uses Angular 7. A Snapcast web socket proxy server is needed to connect Snapcast to HydraPlay over web sockets.
For Windows, there's [Snap.Net](https://github.com/stijnvdb88/snap.net), a control client and player. It runs in the tray and lets you adjust client volumes with just a few clicks. The player simplifies setting up snapclient to play your music through multiple Windows sound devices simultaneously: pc speakers, hdmi audio, any usb audio devices you may have, etc. Snap.Net also runs on Android, and has limited support for iOS.
## 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.
The only requirement is that the player's audio can be redirected into the Snapserver's fifo `/tmp/snapfifo`. In the following configuration hints for [MPD](http://www.musicpd.org/) and [Mopidy](https://www.mopidy.com/) are given, which are base of other audio player solutions, like [Volumio](https://volumio.org/) or [RuneAudio](http://www.runeaudio.com/) (both MPD) or [Pi MusicBox](http://www.pimusicbox.com/) (Mopidy).
The goal is to build the following chain:
audio player software -> snapfifo -> snapserver -> network -> snapclient -> alsa
This [guide](doc/player_setup.md) shows how to configure different players/audio sources to redirect their audio signal into the Snapserver's fifo:
- [MPD](doc/player_setup.md#mpd)
- [Mopidy](doc/player_setup.md#mopidy)
- [FFmpeg](doc/player_setup.md#ffmpeg)
- [mpv](doc/player_setup.md#mpv)
- [MPlayer](doc/player_setup.md#mplayer)
- [Alsa](doc/player_setup.md#alsa)
- [PulseAudio](doc/player_setup.md#pulseaudio)
- [AirPlay](doc/player_setup.md#airplay)
- [Spotify](doc/player_setup.md#spotify)
- [Process](doc/player_setup.md#process)
- [Line-in](doc/player_setup.md#line-in)
- [VLC](doc/player_setup.md#vlc)
## Roadmap
Unordered list of features that should make it into the v1.0
- [X] **Remote control** JSON-RPC API to change client latency, volume, zone,...
- [X] **Android client** JSON-RPC client and Snapclient
- [X] **Streams** Support multiple streams
- [X] **Debian packages** prebuild deb packages
- [X] **Endian** independent code
- [X] **OpenWrt** port Snapclient to OpenWrt
- [X] **Hi-Res audio** support (like 96kHz 24bit)
- [X] **Groups** support multiple Groups of clients ("Zones")
- [X] **Ports** Snapclient for Windows, Mac OS X,...
- [ ] **JSON-RPC** Possibility to add, remove, rename streams
- [ ] **Protocol specification** Snapcast binary streaming protocol, JSON-RPC protocol
snapcast-0.28.0/TODO.md 0000664 0000000 0000000 00000001310 14610511116 0014473 0 ustar 00root root 0000000 0000000 TODO
====
General
-------
- Update Readme.md
- JsonRPC documentation
- Server ping client?
- UDP based audio streaming
Server
------
- [fd stream](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fdsink.html)
- gstreamer snapcast sink plugin?
- "sync" option for streams (realtime reading vs read as much as available)
- #402: Add meta stream that reads the input of other streams (in some fallback hierarchy manner: when the first one plays, use this signal, else if the second is playing, take this, ...).
Client
------
- Add option to not play in sync, i.e. not change the tempo
Issues
------
- Android clean data structures after changing the Server
snapcast-0.28.0/changelog.md 0000664 0000000 0000000 00000057141 14610511116 0015672 0 ustar 00root root 0000000 0000000 # Snapcast changelog
## Version 0.28.0
### Features
- Server: Use filename as title for FileStreams
- Client: Loop through resolved server IPs during connect (Issue #1216)
### Bugfixes
- Server: Fix noise caused by reading half samples (Issue #1170)
- Server: Check open syscall error in PipeStream::do_connect (PR #1150)
- Server: Tweak Airplay support (#1102)
- Server: Lower log severity for shairport-sync (Issue #891)
- Server: Emits notifications for streams with codec=null (Is11sue #1205)
- Server: Fix delayed switching of meta streams (Issue #1187)
- Server: Mixer script calls piling up (Issue #1174)
- Server: Mixer script creates zombie processes (Issue #1157)
- Improve connect handling in meta_mopidy.py
- Improve connect handling in meta_librespot-java.py
- Fix cppcheck issues
### General
- CI: Build debian bookworm and bullseye packages for amd64, arm and arm64
- CI: Add cppcheck static analysis
- Update documentation (PR #1130, PR #1067)
- Delete deprecated Makefiles, CMake is the only supported buildsystem
- Snapweb: Update to v0.7.0
_Johannes Pohl Fri, 19 Apr 2024 00:13:37 +0200_
## Version 0.27.0
### Features
- Server: Configurable default volume for new clients (Issue #910, PR #1024)
- Server: New control script for mopidy: meta_mopidy.py
- Server: New control script for librespot java: meta_librespot-java.py
- Server: Add "mute" stream property
### Bugfixes
- Server: Fix random crash with meta stream (Issue #966)
- Server: Fix compatibility with librespot 0.5-dev (Issue #1063, #1074, #1042)
- Server: Not terminate on malformed json messages (Issue #1049)
- Server: Fix random segfault (Issue #1047)
- Server: Fix growing delay on input stream (Issue #1014)
- Server: Fix segfault with Librespot on Alpine (Issue #1026)
- Server: meta_mpd.py is installed with 755 (Issue #1021, #970)
- Server: Add list of dependecies to meta_mpd.py (Issue #971)
- Server: meta_mpd.py stopped working (Issue #997)
- Client: Not terminate if codec is "null" (Issue #1076)
- Fix test failures (Issue #961)
### General
- Fix compilation on macOS with Xcode 13.4.1 (Issue #1028)
- Fix compilation with boost 1.81.0 (Issue #1082)
- Remove debhelper files from project (moved to SnapOS project)
- SnapOs uses containers to build deb packages (solves Issue #968)
- Snapweb: Update to v0.5.0
_Johannes Pohl Sun, 05 Feb 2023 00:13:37 +0200_
## Version 0.26.0
### Features
- Client: Disconnect from pulse when no audio is available (Issue #927, PR #931)
- Server: New Metadata API for audio streams (Issue #803, #953)
- Server: New Control API for audio streams (Issue #954)
- Server: Lowered minimum buffer from 400ms to 20ms (Issue #329)
### Bugfixes
- Server: systemd.unit starts server after network-online (Issue #950)
### General
- Update documentation (Issue #804, PR #945, PR #951)
- Snapweb: Update to v0.4.0
_Johannes Pohl Wed, 22 Dec 2021 00:13:37 +0200_
## Version 0.25.0
### Features
- Client: Editable PulseAudio properties, e.g. media.role=music (Issue #829)
- Server: Configurable amplitute for silence detection in alsa stream (Issue #846)
### Bugfixes
- Client: Fix crash on Windows when system volume changes (PR #838)
- Client: Removed a log message to stdout for file player backend (Issue #681)
- Server: Fix percent-decoding for stream URIs (Issue #850)
- Server: Fix double quotes in Airplay device names (Issue #851)
- Server: Fix crash when feeding a 16 bit signal into 24 bit flac (Issue #866)
### General
- Server: less verbose librespot logging (Issue #874)
- Snapweb: Update to v0.3.0
- Add unit tests to the project
_Johannes Pohl Sat, 15 May 2021 00:13:37 +0200_
## Version 0.24.0
### Features
- Client: Configurable server for Pulseaudio backend (Issue #779)
### Bugfixes
- Client: Fix dropouts in alsa player backend (Issue #774)
- Client: Fix alsa player volume resetting to max (Issue #735)
- Client: Fix noise while muted for Pulseaudio (Issue #785)
- Client: Android support for opus readded (Issue #789)
- Client: Fix host id for MacBook Pro (later 2016) (Issue #807)
### General
- Snapweb: Update to v0.2.0
- Remove submodules with external libs from the git repository
- Write version and revision (git sha) to log
- Add documentation to the default files (Issue #791)
_Johannes Pohl Sat, 27 Feb 2021 00:13:37 +0200_
## Version 0.23.0
### Features
- Client: Add PulseAudio player backend (Issue #722)
- Client: Configurable buffer time for alsa and pulse players
- Server: If docroot is not configured, a default page is served (Issue #711)
- Server: airplay source supports "password" parameter (Issue #754)
### Bugfixes
- Server: airplay source deletes Shairport's meta pipe on exit (Issue #672)
- Server: alsa source will not send silece when going idle (Issue #729)
- Server: pipe source will not send silence after 3h idle (Issue #741)
- Server: Fix build error on FreeBSD (Issue #752)
- Client: "make install" will set correct user/group for snapclient (Issue #728)
- Client: Fix printing UTF-8 device names on Windows (Issue #732)
- Client: Fix stuttering on alsa player backend (Issue #722, #727)
- Client: Terminate if host is not configured and mDNS is unavailable
### General
- Server: Change librespot parameter "killall" default to false (Issue #746, #724)
- Client: Android uses performance mode "none" to allow effects (Issue #766)
- Snapweb: Update to v0.1.0
- Build: Update CMakeLists.txt to build Snapclient on Android
_Johannes Pohl Sun, 10 Jan 2021 00:13:37 +0200_
## Version 0.22.0
### Features
- Server: Add Meta stream source (Issue #402, #569, #666)
- Client: Add file audio backend (Issue #681)
### Bugfixes
- Add missing define for alsa stream to makefile (Issue #692)
- Fix playback when plugging the headset on Android (Issue #699)
- Server discards old chunks if not consumed (Issue #708)
### General
- Less verbose logging during pipe reconnects (Issue #696)
- Add null encoder for streams used only as input for meta streams
- Snapweb: Change latency range to [-10s, 10s] (Issue #695)
- Update Snapweb, including PR #11, #12, #13, Issues #16, #17
_Johannes Pohl Thu, 15 Oct 2020 00:13:37 +0200_
## Version 0.21.0
### Features
- Server: Support for WebSocket streaming clients
- Server: Install Snapweb web client (Issue #579)
- Server: Resample input to 48000:16:2 when using opus codec
- Server: Add Alsa stream source
### Bugfixes
- make install will setup the snapserver home dir (Issue #643)
- Client retries to open a blocked alsa device (Issue #652)
### General
- debian package generation switched from make to CMake buildsystem
- Reintroduce MACOS define, hopefully not breaking anything on macOS
- Snapcast uses GitHub actions for automated CI/CD
- CMake installs man files (Issue #507)
- Update documentation (Issue #615, #617)
_Johannes Pohl Sun, 13 Sep 2020 00:13:37 +0200_
## Version 0.20.0
### Features
- Client: Windows support (Issue #24)
- Client: add hardware mixer (Issue #318)
- Client: add "script" and "none" mixer (Issue #302)
- Client: add sharingmode for audio device (if supported)
- Logging: configurable sink and filters (Issue #30, #561, #122, #559)
- Librespot: add option "disable-audio-cache=[false|true]"
### Bugfixes
- Fix build failure on FreeBSD (Issue #565)
- Fix calling lsb_release multiple times (Issue #470)
- Client: high CPU load and crash during playback (Issue #609, #628)
- Client: improved handling of USB audio disconnects (Issue #64)
- Client: latency is forgotten (Issue #476, #588, Snapdroid #11)
- Client: fix segfault on mac when playback is paused (Issue #560)
- Client: fix bonjour on mac reports empty IP (Issue #632)
- Client: fix buzzing tone on Android (Issue #23, #24)
- Server: fix crash if client disconnects during connect (Issue #639)
- Server: fix reading metadata from shairport-sync (Issue #624)
- Server: fix crash on FreeBSD if settings.json is empty (Issue #620)
- Server: fix warning about unknown command line options (Issue #635)
- Readme: openWrt documentation (Issue #633)
- Fix setting the daemon's process priority (PR #448)
### General
- Client: use less threads and thus less ressources
- Update links to xiph externals (Issue #637, PR #616)
_Johannes Pohl Sat, 13 Jun 2020 00:13:37 +0200_
## Version 0.19.0
### Features
- Option to not kill all running librespot instances (PR #539)
- Add Airplay cover art to metadata (PR #543)
- Anroid: add support for Oboe audio backend
- Server: configurable PID file (Issue #554)
- Server: configurable persistant storage directory (Issue #554)
- Server: config file options can be overwritten on command line
- Client: PCM stream can be resampled using the "--sampleformat" option
- Librespot: add option "autoplay=[false|true]"
### Bugfixes
- Fix Airplay metadata, port selection and device names (PR #537)
- Fix cmake build when libatomic is needed (PR #540)
- Control: fix random crash (PR #543)
### General
- ALSA: improved latency estimation for better sync
- Improved audio synchronization
- Faster initial sync after client start and reconnect
- Less playback tempo adaptions and jitter (Issue #525)
- Playback is robust against system time changes (Issue #522)
- Less "resyncs" in stream reader that were causing audio dropouts
- Control: quicker response to group volume changes
- Server uses less memory when sending PCM data to a stalled connection
_Johannes Pohl Sat, 14 Mar 2020 00:13:37 +0200_
## Version 0.18.1
### Bugfixes
- Fix random server crash or deadlock during stream client disconnect
- Fix random server crash or deadlock during control client disconnect
- Fix airplay stream buffer allocation (PR #536)
_Johannes Pohl Tue, 28 Jan 2020 00:13:37 +0200_
## Version 0.18.0
### Features
- Add TCP stream reader
- Configurable number of server worker threads
### Bugfixes
- Client: fix hostname reporting on Android
- Fix some small memory leaks
- Fix Librespot stream causing zombie processes (Issue #530)
- Process stream watchdog is configurable (Issue #517)
- Fix Makefile for macOS (Issues #510, #514)
### General
- Refactored stream readers
- Server can run on a single thread
_Johannes Pohl Wed, 22 Jan 2020 00:13:37 +0200_
## Version 0.17.1
### Bugfixes
- Fix compile error if u_char is not defined (Issue #506)
- Fix error "exception unknown codec ogg" (Issue #504)
- Fix random crash during client disconnect
_Johannes Pohl Sat, 23 Nov 2019 00:13:37 +0200_
## Version 0.17.0
### Features
- Support for Opus low-latency codec (PR #4)
### Bugfixes
- CMake: fix check for libatomic (Issue #490, PR #494)
- WebUI: interface.html uses the server's IP for the websocket connection
- Fix warnings (Issue #484)
- Fix lock order inversions and data races identified by thread sanitizer
- Makefiles: fix install targets (PR #493)
- Makefiles: LDFLAGS are added from environment (PR #492)
- CMake: required Boost version is raised to 1.70 (Issue #488)
- Fix crash in websocket server
### General
- Stream server uses less threads (one in total, instead of 1+2n)
- Changing group volume is much more responsive for larger groups
- Unknown snapserver.conf options are logged as warning (Issue #487)
- debian scripts: change usernames back to snapclient and snapserver
_Johannes Pohl Wed, 20 Nov 2019 00:13:37 +0200_
## Version 0.16.0
### Features
- Control server: websocket support for JSON RPC
- Control server: simple webserver integrated to host web UIs
- Control server: bind-to addresses are configurable
- Control server: streams can be added and Removed (PR #443)
- Control server: group names can be changed (PR #467)
- Librespot: add onevent parameter (PR #465)
### Bugfixes
- Fix build on macOS (Issue #474)
### General
- Control server uses less threads (one in total, instead of 1+2n)
- Snapserver: Configuration is moved into a file
- Removed submodules "popl" and "aixlog" to ease build
- Snapcast depends on boost::asio and boost::beast (header only)
- Tidy up code base
- Makefile doesn't statically link libgcc and libstdc++
- debian scripts: change usernames to \_snapclient and \_snapserver
_Johannes Pohl Sat, 13 Oct 2019 00:13:37 +0200_
## Version 0.15.0
### Bugfixes
- Snapserver: fix occasional deadlock
- Snapclient: make systemd dependeny to avahi-daemon optional
- cmake: fix build on FreeBSD
### General
- additional linker flags "ADD_LDFLAGS" can be passed to makefile
- update man pages, fix lintian warnings
- Support Android NDK r17
_Johannes Pohl Sat, 07 Jul 2018 00:13:37 +0200_
## Version 0.14.0
### Features
- Snapserver supports IPv4v6 dual stack and IPv4 + IPv6
### Bugfixes
- cmake: fix check for big endian (Issue #367)
- cmake: fix linking against libatomic (PR #368)
- Snapclient compiles with Android NDK API level 16 (Issue #365)
- Fix compilation errors on FreeBSD (Issue #374, PR #375)
### General
- cmake: make dependency on avahi optional (PR #378)
- cmake: Options to build snapserver and snapclient
- cmake: works on FreeBSD
- Update external libs (JSON for modern C++, ASIO, AixLog)
- Restructured source tree
- Moved Android app into seperate project [snapdroid](https://github.com/badaix/snapdroid)
_Johannes Pohl Fri, 27 Apr 2018 00:13:37 +0200_
## Version 0.13.0
### Features
- Support "volume" parameter for Librespot (PR #273)
- Add support for metatags (PR #319)
### Bugfixes
- Fix overflow in timesync when the system time is many years off
- Zeroconf works with IPv6
- Snapclient unit file depends on avahi-daemon.service (PR #348)
### General
- Drop dependency to external "jsonrpc++"
- Move OpenWrt and Buildroot support into separate project "[SnapOS](https://github.com/badaix/snapos)"
- Add CMake support (not fully replacing Make yet) (PR #212)
- Remove MIPS support for Android (deprecated by Google)
- Use MAC address as default client id (override with "--hostID")
_Johannes Pohl Tue, 04 Mar 2018 00:13:37 +0200_
## Version 0.12.0
### Features
- Support for IPv6 (PR #273, #279)
- Spotify plugin: onstart and onstop parameter (PR #225)
- Snapclient: configurable client id (Issue #249)
- Android: Snapclient support for ARM, MIPS and X86
- Snapserver: Play some silence before going idle (PR #284)
### Bugfixes
- Fix linker error (Issue #255, #274)
- Snapclient: more reliable unique client id (Issue #249, #246)
- Snapserver: fix config file permissions (Issue #251)
- Snapserver: fix crash on `bye` from control client (Issue #238)
- Snapserver: fix crash on port scan (Issue #267)
- Snapserver: fix crash when a malformed message is received (Issue #264)
### General
- Improved logging: Use `--debug` for debug logging
- Log to file: Use `--debug=`
- Improved exception handling and error logging (Issue #276)
- Android: update to NDK r16 and clang++
- hide spotify credentials in json control message (Issue #282)
_Johannes Pohl Tue, 17 Oct 2017 00:13:37 +0200_
## Version 0.11.1
### Bugfixes
- Snapserver produces high CPU load on some systems (Issue #174)
- Snapserver compile error on FreeBSD
### General
- Updated Markdown files (PR #216, #218)
_Johannes Pohl Tue, 21 Mar 2017 00:13:37 +0200_
## Version 0.11.0
### Features
- Don't send audio to muted clients (Issue #109, #150)
- Snapclient multi-instance support (Issue #73)
- daemon can run as different user (default: snapclient, Issue #89)
- Spotify plugin does not require username and password (PR #181)
- Spotify plugin is compatible to librespot's pipe backend (PR #158)
- Clients are organized in Groups
- JSON RPC API: Support batch requests
### Bugfixes
- Compilation error on recent GCC versions (Issues #146, #170)
- Crash when frequently connecting to the control port (Issue #200)
- Snapcast App crashes on Android 4.x (Issue #207)
- Resync issue on macOS (Issue #156)
- Id in JSON RPC API can be String, Number or NULL (Issue #161)
- Use "which" instead of "whereis" to find binaries (PR #196, Issue #185)
- Compiles on lede (Issue #203)
### General
- JSON RPC API is versionized (current version is 2.0.0)
- Restructured Android App to support Groups
_Johannes Pohl Thu, 16 Mar 2017 00:13:37 +0200_
## Version 0.11.0-beta-1
### Features
- Snapclient multi-instance support (Issue #73)
- daemon can run as different user (default: snapclient, Issue #89)
- Spotify plugin does not require username and password (PR #181)
- Spotify plugin is compatible to librespot's pipe backend (PR #158)
- Clients are organized in Groups
- JSON RPC API: Support batch requests
### Bugfixes
- Resync issue on macOS (Issue #156)
- Id in JSON RPC API can be String, Number or NULL (Issue #161)
- Use "which" instead of "whereis" to find binaries (PR #196, Issue #185)
- Compiles on lede (Issue #203)
### General
- JSON RPC API is versionized (current version is 2.0.0)
- Restructured Android App to support Groups
_Johannes Pohl Sat, 04 Mar 2017 00:13:37 +0200_
## Version 0.10.0
### Features
- Added support [process](https://github.com/badaix/snapcast/blob/master/doc/player_setup.md#process) streams:
Snapserver starts a process and reads PCM data from stdout
- Specialized versions for [Spotify](https://github.com/badaix/snapcast/blob/master/doc/player_setup.md#spotify) and [AirPlay](https://github.com/badaix/snapcast/blob/master/doc/player_setup.md#airplay)
### Bugfixes
- Fixed crash during server shutdown
- Fixed Makefile for FreeBSD
- Fixed building of dpk (unsigned .changes file)
### General
- Speed up client and server shutdown
_Johannes Pohl Wed, 16 Nov 2016 00:13:37 +0200_
## Version 0.9.0
### Features
- Added (experimental) support for macOS (make TARGET=MACOS)
### Bugfixes
- Android client: Fixed crash on Nougat (Issue #97)
- Fixed FreeBSD compile error for Snapserver (Issue #107)
- Snapserver randomly dropped JSON control messages
- Long command line options (like `--sampleformat`) didn't work on some systems (Issue #103)
### General
- Updated Android NDK to revision 13
_Johannes Pohl Sat, 22 Oct 2016 00:13:37 +0200_
## Version 0.8.0
### Features
- Added support for FreeBSD (Issue #67)
- Android client: Added Japanese and German translation
- Android client: Added support for ogg (Issue #83)
### Bugfixes
- OpenWRT: makefile automatically sets correct endian (Issue #91)
_Johannes Pohl Sun, 24 Jul 2016 00:13:37 +0200_
## Version 0.7.0
### Features
- Support for HiRes audio (e.g. 96000:24:2) (Issue #13)
- Bitdepth must be one of 8, 16, 24 (=24 bit padded to 32) or 32
- Auto start option for Android (Issue #49)
- Creation mode for the fifo can be configured (Issue #52)
- "-s pipe:///tmp/snapfifo?mode=[read|create]"
### Bugfixes
- Server was sometimes crashing during shutdown
- Exceptions were not properly logged (e.g. unsupported sample rates)
- Fixed default sound card detection on OpenWrt
_Johannes Pohl Sat, 07 May 2016 00:13:37 +0200_
## Version 0.6.0
### Features
- Port to OpenWrt (Issue #18)
### Bugfixes
- Android client: fixed crash if more than two streams are active (Issue #47)
### General
- Support Tremor, an integer only Ogg-Vorbis implementation
- Endian-independent code (Issue #18)
- Cleaned up build process
_Johannes Pohl Sun, 10 Apr 2016 00:02:00 +0200_
## Version 0.5.0
### Features
- Android client: Fast switching of clients between streams
### Bugfixes
- Server: Fixed reading of server.json config file
### General
- Source code cleanups
_Johannes Pohl Fri, 25 Mar 2016 00:02:00 +0200_
## Version 0.4.1
### General
- Debian packages (.deb) are linked statically against libgcc and libstdc++ to improve compatibility
_Johannes Pohl Sat, 12 Mar 2016 12:00:00 +0200_
## Version 0.5.0-beta-2
### Features
- Remote control API (JSON)
- Added version information
- Stream playing state (unknown, idle, playing, inactive) (Issue #34)
- Android client: manually configure snapserver host name
- Android client compatibility improved: armeabi and armeabi-v7 binaries
- Android client: configurable latency
- Improved compatibility to Mopidy (GStreamer) (Issue #23)
### Bugfixes
- Android client: fixed "hide offline" on start
- Store config in /var/lib/snapcast/ when running as daemon (Issue #33)
### General
- README.md: Added resampling command to the Mopidy section (Issue #32)
_Johannes Pohl Wed, 09 Mar 2016 00:02:00 +0200_
## Version 0.5.0-beta-1
### Features
- Remote control API (JSON)
- Get server status, get streams, get active clients, ...
- Assign volume, assign stream, rename client, ...
- Android port of the Snapclient with a remote control app (requires API level 16, Android 4.1)
- Multiple streams ("zones") can be configured using `-s, --stream`
The stream is configured by an URI: path, name, codec, sample format, ...
E.g. `pipe:///tmp/snapfifo?name=Radio&sampleformat=48000:16:2&codec=flac`
or `file:///home/user/some_pcm_file.wav?name=file`
- Added .default file for the service in `/etc/default/snapserver` and `/etc/default/snapclient`.
Default program options should be configured here (e.g. streams)
### Bugfixes
- Pipe reader recovers if the pipe has been reopened
### General
- SnapCast is renamed to Snapcast
- SnapClient => Snapclient
- SnapServer => Snapserver
- Changed default sample rate to 48kHz. The sample rate can be configured per stream `-s "pipe:///tmp/snapfifo?name=default&sampleformat=44100:16:2`. The default can be changed with `--sampleformat 44100:16:2`
- Snapcast protocol:
Less messaging: SampleFormat, Command, Ack, String, not yet final
- Removed dependency to boost
_Johannes Pohl Tue, 09 Feb 2016 13:25:00 +0200_
## Version 0.4.0
### Features
- Debian packages (.deb) for amd64 and armhf
- Added man pages
### Bugfixes
- Snapserver and Snapclient are started as daemon on systemd systems (e.g. ARCH, Debian Jessie)
### General
- Snapserver is started with normal process priority (changed nice from -3 to 0)
_Johannes Pohl Mon, 28 Dec 2015 12:00:00 +0200_
## Version 0.3.4
### Bugfixes
- Fix synchronization bug in FLAC decoder that could cause audible dropouts
_Johannes Pohl Wed, 23 Dec 2015 12:00:00 +0200_
## Version 0.3.3
### Bugfixes
- Fix Segfault when ALSA device has no description
_Johannes Pohl Sun, 15 Nov 2015 12:00:00 +0200_
## Version 0.3.2
### General
- Makefile uses CXX instead of CC to invoke the c++ compiler
### Bugfixes
- Time calculation for PCM chunk play-out was wrong on some gcc versions
_Johannes Pohl Wed, 30 Sep 2015 12:00:00 +0200_
## Version 0.3.1
### General
- Improved stability over WiFi by avoiding simultaneous reads/writes on the socket connection
### Bugfixes
- Fixed a bug in avahi browser
_Johannes Pohl Wed, 26 Aug 2015 12:00:00 +0200_
## Version 0.3.0
### Features
- Configurable codec options. Run `snapserver -c [flac|ogg|pcm]:?` to get supported options for the codec
- Configurable buffer size for the pipe reader (default 20ms, was 50ms before)
- Process priority can be changed as argument to the daemon option `-d`. Default priority is -3
### Bugfixes
- Fixed deadlock in logger
- Fixed occasional timeouts for client to server requests (e.g. time sync commands)
- Client didn't connect to a local server if the loopback device is the only device with an address
### General
- Code clean up
- Refactored encoding for lower latency
_Johannes Pohl Sun, 16 Aug 2015 19:25:51 +0100_
## Version 0.2.1
### Features
- Arch Linux compatibility
_Johannes Pohl Fri, 24 Jul 2015 15:47:00 +0100_
snapcast-0.28.0/client/ 0000775 0000000 0000000 00000000000 14610511116 0014667 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/client/CMakeLists.txt 0000664 0000000 0000000 00000007547 14610511116 0017444 0 ustar 00root root 0000000 0000000 set(CLIENT_SOURCES
client_connection.cpp
controller.cpp
snapclient.cpp
stream.cpp
time_provider.cpp
decoder/pcm_decoder.cpp
decoder/null_decoder.cpp
player/player.cpp
player/file_player.cpp)
set(CLIENT_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${ATOMIC_LIBRARY} common)
set(CLIENT_INCLUDE ${Boost_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/client
${CMAKE_SOURCE_DIR})
if(MACOSX)
# Bonjour
if(BONJOUR_FOUND)
list(APPEND CLIENT_SOURCES browseZeroConf/browse_bonjour.cpp)
endif(BONJOUR_FOUND)
# CoreAudio
add_compile_definitions(HAS_COREAUDIO)
list(APPEND CLIENT_SOURCES player/coreaudio_player.cpp)
find_library(COREAUDIO_LIB CoreAudio)
find_library(COREFOUNDATION_LIB CoreFoundation)
find_library(IOKIT_LIB IOKit)
find_library(AUDIOTOOLBOX_LIB AudioToolbox)
list(APPEND CLIENT_LIBRARIES ${COREAUDIO_LIB} ${COREFOUNDATION_LIB}
${IOKIT_LIB} ${AUDIOTOOLBOX_LIB})
elseif(WIN32)
list(APPEND CLIENT_SOURCES player/wasapi_player.cpp)
list(
APPEND
CLIENT_LIBRARIES
wsock32
ws2_32
avrt
ksuser
iphlpapi)
elseif(NOT ANDROID)
# Avahi
if(AVAHI_FOUND)
list(APPEND CLIENT_SOURCES browseZeroConf/browse_avahi.cpp)
list(APPEND CLIENT_LIBRARIES ${AVAHI_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${AVAHI_INCLUDE_DIRS})
endif(AVAHI_FOUND)
# ALSA
if(ALSA_FOUND)
list(APPEND CLIENT_SOURCES player/alsa_player.cpp)
list(APPEND CLIENT_LIBRARIES ${ALSA_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${ALSA_INCLUDE_DIRS})
endif(ALSA_FOUND)
if(PULSE_FOUND)
list(APPEND CLIENT_SOURCES player/pulse_player.cpp)
list(APPEND CLIENT_LIBRARIES ${PULSE_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${PULSE_INCLUDE_DIRS})
endif(PULSE_FOUND)
endif(MACOSX)
if(ANDROID)
list(APPEND CLIENT_LIBRARIES oboe::oboe)
list(APPEND CLIENT_LIBRARIES boost::boost)
list(APPEND CLIENT_LIBRARIES flac::flac)
list(APPEND CLIENT_LIBRARIES opus::opus)
list(APPEND CLIENT_LIBRARIES tremor::tremor)
list(APPEND CLIENT_LIBRARIES ogg::ogg)
list(APPEND CLIENT_SOURCES player/oboe_player.cpp)
list(APPEND CLIENT_SOURCES player/opensl_player.cpp)
list(APPEND CLIENT_SOURCES decoder/flac_decoder.cpp)
list(APPEND CLIENT_SOURCES decoder/ogg_decoder.cpp)
list(APPEND CLIENT_SOURCES decoder/opus_decoder.cpp)
list(APPEND CLIENT_LIBRARIES OpenSLES)
else()
# Tremor (fixed-point) or libvorbis (floating-point)
if(TREMOR_FOUND)
list(APPEND CLIENT_LIBRARIES ${TREMOR_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${TREMOR_INCLUDE_DIRS})
elseif(VORBIS_FOUND)
list(APPEND CLIENT_LIBRARIES ${VORBIS_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${VORBIS_INCLUDE_DIRS})
endif(TREMOR_FOUND)
# if OGG then tremor or vorbis
if(OGG_FOUND)
list(APPEND CLIENT_SOURCES decoder/ogg_decoder.cpp)
list(APPEND CLIENT_LIBRARIES ${OGG_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${OGG_INCLUDE_DIRS})
endif(OGG_FOUND)
if(FLAC_FOUND)
list(APPEND CLIENT_SOURCES decoder/flac_decoder.cpp)
list(APPEND CLIENT_LIBRARIES ${FLAC_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${FLAC_INCLUDE_DIRS})
endif(FLAC_FOUND)
if(OPUS_FOUND)
list(APPEND CLIENT_SOURCES decoder/opus_decoder.cpp)
list(APPEND CLIENT_LIBRARIES ${OPUS_LIBRARIES})
list(APPEND CLIENT_INCLUDE ${OPUS_INCLUDE_DIRS})
endif(OPUS_FOUND)
endif()
include_directories(${CLIENT_INCLUDE})
if(ANDROID)
add_executable(libsnapclient.so ${CLIENT_SOURCES})
target_link_libraries(libsnapclient.so ${CLIENT_LIBRARIES} log OpenSLES)
else()
add_executable(snapclient ${CLIENT_SOURCES})
target_link_libraries(snapclient ${CLIENT_LIBRARIES})
install(
TARGETS snapclient
COMPONENT client
DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(
FILES snapclient.1
COMPONENT client
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
install(
FILES etc/snapcast.svg
COMPONENT client
DESTINATION ${CMAKE_INSTALL_DATADIR}/pixmaps)
endif()
snapcast-0.28.0/client/browseZeroConf/ 0000775 0000000 0000000 00000000000 14610511116 0017636 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/client/browseZeroConf/browse_avahi.cpp 0000664 0000000 0000000 00000017777 14610511116 0023036 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "browse_avahi.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/snap_exception.hpp"
// standard headers
#include
#include
static AvahiSimplePoll* simple_poll = nullptr;
static constexpr auto LOG_TAG = "Avahi";
BrowseAvahi::BrowseAvahi() : client_(nullptr), sb_(nullptr)
{
}
BrowseAvahi::~BrowseAvahi()
{
cleanUp();
}
void BrowseAvahi::cleanUp()
{
if (sb_ != nullptr)
avahi_service_browser_free(sb_);
sb_ = nullptr;
if (client_ != nullptr)
avahi_client_free(client_);
client_ = nullptr;
if (simple_poll != nullptr)
avahi_simple_poll_free(simple_poll);
simple_poll = nullptr;
}
void BrowseAvahi::resolve_callback(AvahiServiceResolver* r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol,
AvahiResolverEvent event, const char* name, const char* type, const char* domain, const char* host_name,
const AvahiAddress* address, uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata)
{
auto* browseAvahi = static_cast(userdata);
assert(r);
/* Called whenever a service has been resolved successfully or timed out */
switch (event)
{
case AVAHI_RESOLVER_FAILURE:
LOG(ERROR, LOG_TAG) << "(Resolver) Failed to resolve service '" << name << "' of type '" << type << "' in domain '" << domain
<< "': " << avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))) << "\n";
break;
case AVAHI_RESOLVER_FOUND:
{
char a[AVAHI_ADDRESS_STR_MAX], *t;
LOG(INFO, LOG_TAG) << "Service '" << name << "' of type '" << type << "' in domain '" << domain << "':\n";
avahi_address_snprint(a, sizeof(a), address);
browseAvahi->result_.host = host_name;
browseAvahi->result_.ip = a;
browseAvahi->result_.port = port;
// protocol seems to be unreliable (0 for IPv4 and for IPv6)
browseAvahi->result_.ip_version = (browseAvahi->result_.ip.find(':') == std::string::npos) ? (IPVersion::IPv4) : (IPVersion::IPv6);
browseAvahi->result_.valid = true;
browseAvahi->result_.iface_idx = interface;
t = avahi_string_list_to_string(txt);
LOG(INFO, LOG_TAG) << "\t" << host_name << ":" << port << " (" << a << ")\n";
LOG(DEBUG, LOG_TAG) << "\tTXT=" << t << "\n";
LOG(DEBUG, LOG_TAG) << "\tProto=" << static_cast(protocol) << "\n";
LOG(DEBUG, LOG_TAG) << "\tcookie is " << avahi_string_list_get_service_cookie(txt) << "\n";
LOG(DEBUG, LOG_TAG) << "\tis_local: " << !((flags & AVAHI_LOOKUP_RESULT_LOCAL) == 0) << "\n";
LOG(DEBUG, LOG_TAG) << "\tour_own: " << !((flags & AVAHI_LOOKUP_RESULT_OUR_OWN) == 0) << "\n";
LOG(DEBUG, LOG_TAG) << "\twide_area: " << !((flags & AVAHI_LOOKUP_RESULT_WIDE_AREA) == 0) << "\n";
LOG(DEBUG, LOG_TAG) << "\tmulticast: " << !((flags & AVAHI_LOOKUP_RESULT_MULTICAST) == 0) << "\n";
LOG(DEBUG, LOG_TAG) << "\tcached: " << !((flags & AVAHI_LOOKUP_RESULT_CACHED) == 0) << "\n";
avahi_free(t);
}
}
avahi_service_resolver_free(r);
}
void BrowseAvahi::browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name,
const char* type, const char* domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata)
{
// AvahiClient* client = (AvahiClient*)userdata;
auto* browseAvahi = static_cast(userdata);
assert(b);
/* Called whenever a new services becomes available on the LAN or is removed from the LAN */
switch (event)
{
case AVAHI_BROWSER_FAILURE:
LOG(ERROR, LOG_TAG) << "(Browser) " << avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))) << "\n";
avahi_simple_poll_quit(simple_poll);
return;
case AVAHI_BROWSER_NEW:
LOG(INFO, LOG_TAG) << "(Browser) NEW: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
/* We ignore the returned resolver object. In the callback
function we free it. If the server is terminated before
the callback function is called the server will free
the resolver for us. */
if ((avahi_service_resolver_new(browseAvahi->client_, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, static_cast(0),
resolve_callback, userdata)) == nullptr)
LOG(ERROR, LOG_TAG) << "Failed to resolve service '" << name << "': " << avahi_strerror(avahi_client_errno(browseAvahi->client_)) << "\n";
break;
case AVAHI_BROWSER_REMOVE:
LOG(INFO, LOG_TAG) << "(Browser) REMOVE: service '" << name << "' of type '" << type << "' in domain '" << domain << "'\n";
break;
case AVAHI_BROWSER_ALL_FOR_NOW:
case AVAHI_BROWSER_CACHE_EXHAUSTED:
LOG(INFO, LOG_TAG) << "(Browser) " << (event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW") << "\n";
break;
}
}
void BrowseAvahi::client_callback(AvahiClient* c, AvahiClientState state, AVAHI_GCC_UNUSED void* userdata)
{
assert(c);
/* Called whenever the client or server state changes */
// BrowseAvahi* browseAvahi = static_cast(userdata);
if (state == AVAHI_CLIENT_FAILURE)
{
LOG(ERROR, LOG_TAG) << "Server connection failure: " << avahi_strerror(avahi_client_errno(c)) << "\n";
avahi_simple_poll_quit(simple_poll);
}
}
bool BrowseAvahi::browse(const std::string& serviceName, mDNSResult& result, int timeout)
{
try
{
/* Allocate main loop object */
if ((simple_poll = avahi_simple_poll_new()) == nullptr)
throw SnapException("BrowseAvahi - Failed to create simple poll object");
/* Allocate a new client */
int error;
if ((client_ = avahi_client_new(avahi_simple_poll_get(simple_poll), static_cast(0), client_callback, this, &error)) == nullptr)
throw SnapException("BrowseAvahi - Failed to create client: " + std::string(avahi_strerror(error)));
/* Create the service browser */
if ((sb_ = avahi_service_browser_new(client_, AVAHI_IF_UNSPEC, AVAHI_PROTO_INET, serviceName.c_str(), nullptr, static_cast(0),
browse_callback, this)) == nullptr)
throw SnapException("BrowseAvahi - Failed to create service browser: " + std::string(avahi_strerror(avahi_client_errno(client_))));
result_.valid = false;
while (timeout > 0)
{
avahi_simple_poll_iterate(simple_poll, 100);
timeout -= 100;
if (result_.valid)
{
result = result_;
cleanUp();
return true;
}
}
cleanUp();
return false;
}
catch (...)
{
cleanUp();
throw;
}
}
snapcast-0.28.0/client/browseZeroConf/browse_avahi.hpp 0000664 0000000 0000000 00000004165 14610511116 0023026 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
class BrowseAvahi;
// local headers
#include "browse_mdns.hpp"
// 3rd party headers
#include
#include
#include
#include
#include
class BrowseAvahi : public BrowsemDNS
{
public:
BrowseAvahi();
~BrowseAvahi();
bool browse(const std::string& serviceName, mDNSResult& result, int timeout) override;
private:
void cleanUp();
static void resolve_callback(AvahiServiceResolver* r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol,
AvahiResolverEvent event, const char* name, const char* type, const char* domain, const char* host_name,
const AvahiAddress* address, uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata);
static void browse_callback(AvahiServiceBrowser* b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name,
const char* type, const char* domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata);
static void client_callback(AvahiClient* c, AvahiClientState state, AVAHI_GCC_UNUSED void* userdata);
AvahiClient* client_;
mDNSResult result_;
AvahiServiceBrowser* sb_;
};
snapcast-0.28.0/client/browseZeroConf/browse_bonjour.cpp 0000664 0000000 0000000 00000020630 14610511116 0023402 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "browse_bonjour.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/snap_exception.hpp"
// standard headers
#include
#include
#ifdef WINDOWS
#include
#include
#else
#include
#include
#endif
using namespace std;
static constexpr auto LOG_TAG = "Bonjour";
struct DNSServiceRefDeleter
{
void operator()(DNSServiceRef* ref)
{
DNSServiceRefDeallocate(*ref);
delete ref;
}
};
using DNSServiceHandle = std::unique_ptr;
string BonjourGetError(DNSServiceErrorType error)
{
switch (error)
{
case kDNSServiceErr_NoError:
return "NoError";
default:
case kDNSServiceErr_Unknown:
return "Unknown";
case kDNSServiceErr_NoSuchName:
return "NoSuchName";
case kDNSServiceErr_NoMemory:
return "NoMemory";
case kDNSServiceErr_BadParam:
return "BadParam";
case kDNSServiceErr_BadReference:
return "BadReference";
case kDNSServiceErr_BadState:
return "BadState";
case kDNSServiceErr_BadFlags:
return "BadFlags";
case kDNSServiceErr_Unsupported:
return "Unsupported";
case kDNSServiceErr_NotInitialized:
return "NotInitialized";
case kDNSServiceErr_AlreadyRegistered:
return "AlreadyRegistered";
case kDNSServiceErr_NameConflict:
return "NameConflict";
case kDNSServiceErr_Invalid:
return "Invalid";
case kDNSServiceErr_Firewall:
return "Firewall";
case kDNSServiceErr_Incompatible:
return "Incompatible";
case kDNSServiceErr_BadInterfaceIndex:
return "BadInterfaceIndex";
case kDNSServiceErr_Refused:
return "Refused";
case kDNSServiceErr_NoSuchRecord:
return "NoSuchRecord";
case kDNSServiceErr_NoAuth:
return "NoAuth";
case kDNSServiceErr_NoSuchKey:
return "NoSuchKey";
case kDNSServiceErr_NATTraversal:
return "NATTraversal";
case kDNSServiceErr_DoubleNAT:
return "DoubleNAT";
case kDNSServiceErr_BadTime:
return "BadTime";
case kDNSServiceErr_BadSig:
return "BadSig";
case kDNSServiceErr_BadKey:
return "BadKey";
case kDNSServiceErr_Transient:
return "Transient";
case kDNSServiceErr_ServiceNotRunning:
return "ServiceNotRunning";
case kDNSServiceErr_NATPortMappingUnsupported:
return "NATPortMappingUnsupported";
case kDNSServiceErr_NATPortMappingDisabled:
return "NATPortMappingDisabled";
case kDNSServiceErr_NoRouter:
return "NoRouter";
case kDNSServiceErr_PollingMode:
return "PollingMode";
case kDNSServiceErr_Timeout:
return "Timeout";
}
}
struct mDNSReply
{
string name, regtype, domain;
};
struct mDNSResolve
{
string fullName;
uint16_t port;
};
#define CHECKED(err) \
if ((err) != kDNSServiceErr_NoError) \
throw SnapException(BonjourGetError(err) + ":" + to_string(__LINE__));
void runService(const DNSServiceHandle& service)
{
if (!*service)
return;
auto socket = DNSServiceRefSockFD(*service);
fd_set set;
FD_ZERO(&set);
FD_SET(socket, &set);
timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
while (select(FD_SETSIZE, &set, NULL, NULL, &timeout))
{
CHECKED(DNSServiceProcessResult(*service));
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
}
}
bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int /*timeout*/)
{
result.valid = false;
// Discover
deque replyCollection;
{
DNSServiceHandle service(new DNSServiceRef(NULL));
CHECKED(DNSServiceBrowse(
service.get(), 0, 0, serviceName.c_str(), "local.",
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode, const char* serviceName,
const char* regtype, const char* replyDomain, void* context)
{
auto replyCollection = static_cast*>(context);
CHECKED(errorCode);
replyCollection->push_back(mDNSReply{string(serviceName), string(regtype), string(replyDomain)});
},
&replyCollection));
runService(service);
}
// Resolve
deque resolveCollection;
{
DNSServiceHandle service(new DNSServiceRef(NULL));
for (auto& reply : replyCollection)
CHECKED(DNSServiceResolve(
service.get(), 0, 0, reply.name.c_str(), reply.regtype.c_str(), reply.domain.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode, const char* /*fullName*/,
const char* hosttarget, uint16_t port, uint16_t /*txtLen*/, const unsigned char* /*txtRecord*/, void* context)
{
auto resultCollection = static_cast*>(context);
CHECKED(errorCode);
resultCollection->push_back(mDNSResolve{string(hosttarget), ntohs(port)});
},
&resolveCollection));
runService(service);
}
// DNS/mDNS Resolve
deque resultCollection(resolveCollection.size(), mDNSResult{});
{
DNSServiceHandle service(new DNSServiceRef(NULL));
unsigned i = 0;
for (auto& resolve : resolveCollection)
{
resultCollection[i].port = resolve.port;
CHECKED(DNSServiceGetAddrInfo(
service.get(), kDNSServiceFlagsLongLivedQuery, 0, kDNSServiceProtocol_IPv4, resolve.fullName.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t interfaceIndex, DNSServiceErrorType /*errorCode*/, const char* hostname,
const sockaddr* address, uint32_t /*ttl*/, void* context)
{
auto result = static_cast(context);
result->host = string(hostname);
result->ip_version = (address->sa_family == AF_INET) ? (IPVersion::IPv4) : (IPVersion::IPv6);
result->iface_idx = static_cast(interfaceIndex);
char hostIP[NI_MAXHOST];
char hostService[NI_MAXSERV];
if (getnameinfo(address, sizeof(*address), hostIP, sizeof(hostIP), hostService, sizeof(hostService), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
result->ip = string(hostIP);
else
return;
result->valid = true;
},
&resultCollection[i++]));
}
runService(service);
}
resultCollection.erase(std::remove_if(resultCollection.begin(), resultCollection.end(), [](const mDNSResult& res) { return res.ip.empty(); }),
resultCollection.end());
if (resultCollection.empty())
return false;
if (resultCollection.size() > 1)
LOG(NOTICE, LOG_TAG) << "Multiple servers found. Using first" << endl;
result = resultCollection.front();
return true;
}
#undef CHECKED
snapcast-0.28.0/client/browseZeroConf/browse_bonjour.hpp 0000664 0000000 0000000 00000001761 14610511116 0023413 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
class BrowseBonjour;
// local headers
#include "browse_mdns.hpp"
// 3rd party headers
#include
class BrowseBonjour : public BrowsemDNS
{
public:
bool browse(const std::string& serviceName, mDNSResult& result, int timeout) override;
};
snapcast-0.28.0/client/browseZeroConf/browse_mdns.hpp 0000664 0000000 0000000 00000002600 14610511116 0022667 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// standard headers
#include
#include
enum IPVersion
{
IPv4 = 0,
IPv6 = 1
};
struct mDNSResult
{
mDNSResult() : ip_version(IPv4), iface_idx(0), port(0), valid(false)
{
}
IPVersion ip_version;
int iface_idx;
std::string ip;
std::string host;
uint16_t port;
bool valid;
};
class BrowsemDNS
{
public:
virtual bool browse(const std::string& serviceName, mDNSResult& result, int timeout) = 0;
};
#if defined(HAS_AVAHI)
#include "browse_avahi.hpp"
using BrowseZeroConf = BrowseAvahi;
#elif defined(HAS_BONJOUR)
#include "browse_bonjour.hpp"
using BrowseZeroConf = BrowseBonjour;
#endif
snapcast-0.28.0/client/build_android.sh 0000775 0000000 0000000 00000001265 14610511116 0020031 0 ustar 00root root 0000000 0000000 #/bin/sh
export NDK_DIR="$1"
export JNI_LIBS_DIR="$2"
export TOOLCHAIN="$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64"
export ARCH=x86
make clean;
make TARGET=ANDROID -j 4; $TOOLCHAIN/x86_64-linux-android/bin/strip ./snapclient; cp ./snapclient "$JNI_LIBS_DIR/x86_64/libsnapclient.so"; mv ./snapclient "$JNI_LIBS_DIR/x86/libsnapclient.so"
export ARCH=arm
make clean;
make TARGET=ANDROID -j 4; $TOOLCHAIN/arm-linux-androideabi/bin/strip ./snapclient; mv ./snapclient "$JNI_LIBS_DIR/armeabi-v7a/libsnapclient.so"
export ARCH=aarch64
make clean;
make TARGET=ANDROID -j 4; $TOOLCHAIN/aarch64-linux-android/bin/strip ./snapclient; mv ./snapclient "$JNI_LIBS_DIR/arm64-v8a/libsnapclient.so"
snapcast-0.28.0/client/build_android_all.sh 0000775 0000000 0000000 00000000217 14610511116 0020655 0 ustar 00root root 0000000 0000000 #/bin/sh
export NDK_DIR_ARM="$1-arm"
export NDK_DIR_ARM64="$1-arm64"
export NDK_DIR_X86="$1-x86"
export JNI_LIBS_DIR="$2"
./build_android.sh
snapcast-0.28.0/client/client_connection.cpp 0000664 0000000 0000000 00000026111 14610511116 0021071 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "client_connection.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/str_compat.hpp"
// 3rd party headers
#include
#include
#include
// standard headers
#include
using namespace std;
static constexpr auto LOG_TAG = "Connection";
PendingRequest::PendingRequest(const boost::asio::strand& strand, uint16_t reqId, const MessageHandler& handler)
: id_(reqId), timer_(strand), strand_(strand), handler_(handler)
{
}
PendingRequest::~PendingRequest()
{
handler_ = nullptr;
timer_.cancel();
}
void PendingRequest::setValue(std::unique_ptr value)
{
boost::asio::post(strand_,
[this, self = shared_from_this(), val = std::move(value)]() mutable
{
timer_.cancel();
if (handler_)
handler_({}, std::move(val));
});
}
uint16_t PendingRequest::id() const
{
return id_;
}
void PendingRequest::startTimer(const chronos::usec& timeout)
{
timer_.expires_after(timeout);
timer_.async_wait(
[this, self = shared_from_this()](boost::system::error_code ec)
{
if (!handler_)
return;
if (!ec)
{
// !ec => expired => timeout
handler_(boost::asio::error::timed_out, nullptr);
handler_ = nullptr;
}
else if (ec != boost::asio::error::operation_aborted)
{
// ec != aborted => not cancelled (in setValue)
// => should not happen, but who knows => pass the error to the handler
handler_(ec, nullptr);
}
});
}
bool PendingRequest::operator<(const PendingRequest& other) const
{
return (id_ < other.id());
}
ClientConnection::ClientConnection(boost::asio::io_context& io_context, const ClientSettings::Server& server)
: strand_(boost::asio::make_strand(io_context.get_executor())), resolver_(strand_), socket_(strand_), reqId_(1), server_(server)
{
base_msg_size_ = base_message_.getSize();
buffer_.resize(base_msg_size_);
}
ClientConnection::~ClientConnection()
{
disconnect();
}
std::string ClientConnection::getMacAddress()
{
std::string mac =
#ifndef WINDOWS
::getMacAddress(socket_.native_handle());
#else
::getMacAddress(socket_.local_endpoint().address().to_string());
#endif
if (mac.empty())
mac = "00:00:00:00:00:00";
LOG(INFO, LOG_TAG) << "My MAC: \"" << mac << "\", socket: " << socket_.native_handle() << "\n";
return mac;
}
void ClientConnection::connect(const ResultHandler& handler)
{
tcp::resolver::query query(server_.host, cpt::to_string(server_.port), boost::asio::ip::resolver_query_base::numeric_service);
boost::system::error_code ec;
LOG(INFO, LOG_TAG) << "Resolving host IP for: " << server_.host << "\n";
auto iterator = resolver_.resolve(query, ec);
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to resolve host '" << server_.host << "', error: " << ec.message() << "\n";
handler(ec);
return;
}
for (const auto& iter : iterator)
LOG(DEBUG, LOG_TAG) << "Resolved IP: " << iter.endpoint().address().to_string() << "\n";
for (const auto& iter : iterator)
{
LOG(INFO, LOG_TAG) << "Connecting to " << iter.endpoint() << "\n";
socket_.connect(*iterator, ec);
if (!ec || (ec == boost::system::errc::interrupted))
{
// We were successful or interrupted, e.g. by sig int
break;
}
}
if (ec)
LOG(ERROR, LOG_TAG) << "Failed to connect to host '" << server_.host << "', error: " << ec.message() << "\n";
else
LOG(NOTICE, LOG_TAG) << "Connected to " << socket_.remote_endpoint().address().to_string() << endl;
handler(ec);
#if 0
resolver_.async_resolve(query, host_, cpt::to_string(port_), [this, handler](const boost::system::error_code& ec, tcp::resolver::results_type results) {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to resolve host '" << host_ << "', error: " << ec.message() << "\n";
handler(ec);
return;
}
resolver_.cancel();
socket_.async_connect(*results, [this, handler](const boost::system::error_code& ec) {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to connect to host '" << host_ << "', error: " << ec.message() << "\n";
handler(ec);
return;
}
LOG(NOTICE, LOG_TAG) << "Connected to " << socket_.remote_endpoint().address().to_string() << endl;
handler(ec);
getNextMessage();
});
});
#endif
}
void ClientConnection::disconnect()
{
LOG(DEBUG, LOG_TAG) << "Disconnecting\n";
if (!socket_.is_open())
{
LOG(DEBUG, LOG_TAG) << "Not connected\n";
return;
}
boost::system::error_code ec;
socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
if (ec)
LOG(ERROR, LOG_TAG) << "Error in socket shutdown: " << ec.message() << endl;
socket_.close(ec);
if (ec)
LOG(ERROR, LOG_TAG) << "Error in socket close: " << ec.message() << endl;
boost::asio::post(strand_, [this]() { pendingRequests_.clear(); });
LOG(DEBUG, LOG_TAG) << "Disconnected\n";
}
void ClientConnection::sendNext()
{
auto& message = messages_.front();
static boost::asio::streambuf streambuf;
std::ostream stream(&streambuf);
tv t;
message.msg->sent = t;
message.msg->serialize(stream);
auto handler = message.handler;
boost::asio::async_write(socket_, streambuf,
[this, handler](boost::system::error_code ec, std::size_t length)
{
if (ec)
LOG(ERROR, LOG_TAG) << "Failed to send message, error: " << ec.message() << "\n";
else
LOG(TRACE, LOG_TAG) << "Wrote " << length << " bytes to socket\n";
messages_.pop_front();
if (handler)
handler(ec);
if (!messages_.empty())
sendNext();
});
}
void ClientConnection::send(const msg::message_ptr& message, const ResultHandler& handler)
{
boost::asio::post(strand_,
[this, message, handler]()
{
messages_.emplace_back(message, handler);
if (messages_.size() > 1)
{
LOG(DEBUG, LOG_TAG) << "outstanding async_write\n";
return;
}
sendNext();
});
}
void ClientConnection::sendRequest(const msg::message_ptr& message, const chronos::usec& timeout, const MessageHandler& handler)
{
boost::asio::post(strand_,
[this, message, timeout, handler]()
{
pendingRequests_.erase(
std::remove_if(pendingRequests_.begin(), pendingRequests_.end(), [](std::weak_ptr request) { return request.expired(); }),
pendingRequests_.end());
unique_ptr response(nullptr);
if (++reqId_ >= 10000)
reqId_ = 1;
message->id = reqId_;
auto request = make_shared(strand_, reqId_, handler);
pendingRequests_.push_back(request);
request->startTimer(timeout);
send(message,
[handler](const boost::system::error_code& ec)
{
if (ec)
handler(ec, nullptr);
});
});
}
void ClientConnection::getNextMessage(const MessageHandler& handler)
{
boost::asio::async_read(socket_, boost::asio::buffer(buffer_, base_msg_size_),
[this, handler](boost::system::error_code ec, std::size_t length) mutable
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error reading message header of length " << length << ": " << ec.message() << "\n";
if (handler)
handler(ec, nullptr);
return;
}
base_message_.deserialize(buffer_.data());
tv t;
base_message_.received = t;
// LOG(TRACE, LOG_TAG) << "getNextMessage: " << base_message_.type << ", size: " << base_message_.size << ", id: " <<
// base_message_.id << ", refers: " << base_message_.refersTo << "\n";
if (base_message_.type > message_type::kLast)
{
LOG(ERROR, LOG_TAG) << "unknown message type received: " << base_message_.type << ", size: " << base_message_.size << "\n";
if (handler)
handler(boost::asio::error::invalid_argument, nullptr);
return;
}
else if (base_message_.size > msg::max_size)
{
LOG(ERROR, LOG_TAG) << "received message of type " << base_message_.type << " to large: " << base_message_.size << "\n";
if (handler)
handler(boost::asio::error::invalid_argument, nullptr);
return;
}
if (base_message_.size > buffer_.size())
buffer_.resize(base_message_.size);
boost::asio::async_read(socket_, boost::asio::buffer(buffer_, base_message_.size),
[this, handler](boost::system::error_code ec, std::size_t length) mutable
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error reading message body of length " << length << ": " << ec.message() << "\n";
if (handler)
handler(ec, nullptr);
return;
}
auto response = msg::factory::createMessage(base_message_, buffer_.data());
if (!response)
LOG(WARNING, LOG_TAG) << "Failed to deserialize message of type: " << base_message_.type << "\n";
for (auto iter = pendingRequests_.begin(); iter != pendingRequests_.end(); ++iter)
{
auto request = *iter;
if (auto req = request.lock())
{
if (req->id() == base_message_.refersTo)
{
req->setValue(std::move(response));
pendingRequests_.erase(iter);
getNextMessage(handler);
return;
}
}
}
if (handler)
handler(ec, std::move(response));
});
});
}
snapcast-0.28.0/client/client_connection.hpp 0000664 0000000 0000000 00000012014 14610511116 0021073 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "client_settings.hpp"
#include "common/message/factory.hpp"
#include "common/message/message.hpp"
#include "common/time_defs.hpp"
// 3rd party headers
#include
#include
#include
#include
// standard headers
#include
#include
#include
using boost::asio::ip::tcp;
class ClientConnection;
template
using MessageHandler = std::function)>;
/// Used to synchronize server requests (wait for server response)
class PendingRequest : public std::enable_shared_from_this
{
public:
PendingRequest(const boost::asio::strand& strand, uint16_t reqId, const MessageHandler& handler);
virtual ~PendingRequest();
/// Set the response for the pending request and passes it to the handler
/// @param value the response message
void setValue(std::unique_ptr value);
/// @return the id of the request
uint16_t id() const;
/// Start the timer for the request
/// @param timeout the timeout to wait for the reception of the response
void startTimer(const chronos::usec& timeout);
/// Needed to put the requests in a container
bool operator<(const PendingRequest& other) const;
private:
uint16_t id_;
boost::asio::steady_timer timer_;
boost::asio::strand strand_;
MessageHandler handler_;
};
/// Endpoint of the server connection
/**
* Server connection endpoint.
* Messages are sent to the server with the "send" method (async).
* Messages are sent sync to server with the sendReq method.
*/
class ClientConnection
{
public:
using ResultHandler = std::function;
/// c'tor
ClientConnection(boost::asio::io_context& io_context, const ClientSettings::Server& server);
/// d'tor
virtual ~ClientConnection();
/// async connect
/// @param handler async result handler
void connect(const ResultHandler& handler);
/// disconnect the socket
void disconnect();
/// async send a message
/// @param message the message
/// @param handler the result handler
void send(const msg::message_ptr& message, const ResultHandler& handler);
/// Send request to the server and wait for answer
/// @param message the message
/// @param timeout the send timeout
/// @param handler async result handler with the response message or error
void sendRequest(const msg::message_ptr& message, const chronos::usec& timeout, const MessageHandler& handler);
/// @sa sendRequest with templated response message
template
void sendRequest(const msg::message_ptr& message, const chronos::usec& timeout, const MessageHandler& handler)
{
sendRequest(message, timeout,
[handler](const boost::system::error_code& ec, std::unique_ptr response)
{
if (ec)
handler(ec, nullptr);
else if (auto casted_response = msg::message_cast(std::move(response)))
handler(ec, std::move(casted_response));
else
handler(boost::system::errc::make_error_code(boost::system::errc::bad_message), nullptr);
});
}
std::string getMacAddress();
/// async get the next message
/// @param handler the next received message or error
void getNextMessage(const MessageHandler& handler);
protected:
void sendNext();
msg::BaseMessage base_message_;
std::vector buffer_;
size_t base_msg_size_;
boost::asio::strand strand_;
tcp::resolver resolver_;
tcp::socket socket_;
std::vector> pendingRequests_;
uint16_t reqId_;
ClientSettings::Server server_;
struct PendingMessage
{
PendingMessage(const msg::message_ptr& msg, ResultHandler handler) : msg(msg), handler(handler)
{
}
msg::message_ptr msg;
ResultHandler handler;
};
std::deque messages_;
};
snapcast-0.28.0/client/client_settings.hpp 0000664 0000000 0000000 00000003430 14610511116 0020576 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "common/sample_format.hpp"
#include "player/pcm_device.hpp"
// standard headers
#include
struct ClientSettings
{
enum class SharingMode
{
unspecified,
exclusive,
shared
};
struct Mixer
{
enum class Mode
{
hardware,
software,
script,
none
};
Mode mode{Mode::software};
std::string parameter{""};
};
struct Server
{
std::string host{""};
size_t port{1704};
};
struct Player
{
std::string player_name{""};
std::string parameter{""};
int latency{0};
player::PcmDevice pcm_device;
SampleFormat sample_format;
SharingMode sharing_mode{SharingMode::unspecified};
Mixer mixer;
};
struct Logging
{
std::string sink{""};
std::string filter{"*:info"};
};
size_t instance{1};
std::string host_id;
Server server;
Player player;
Logging logging;
};
snapcast-0.28.0/client/controller.cpp 0000664 0000000 0000000 00000035661 14610511116 0017571 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
// prototype/interface header file
#include "controller.hpp"
// local headers
#include "decoder/null_decoder.hpp"
#include "decoder/pcm_decoder.hpp"
#if defined(HAS_OGG) && (defined(HAS_TREMOR) || defined(HAS_VORBIS))
#include "decoder/ogg_decoder.hpp"
#endif
#if defined(HAS_FLAC)
#include "decoder/flac_decoder.hpp"
#endif
#if defined(HAS_OPUS)
#include "decoder/opus_decoder.hpp"
#endif
#ifdef HAS_ALSA
#include "player/alsa_player.hpp"
#endif
#ifdef HAS_PULSE
#include "player/pulse_player.hpp"
#endif
#ifdef HAS_OPENSL
#include "player/opensl_player.hpp"
#endif
#ifdef HAS_OBOE
#include "player/oboe_player.hpp"
#endif
#ifdef HAS_COREAUDIO
#include "player/coreaudio_player.hpp"
#endif
#ifdef HAS_WASAPI
#include "player/wasapi_player.hpp"
#endif
#include "player/file_player.hpp"
#include "browseZeroConf/browse_mdns.hpp"
#include "common/aixlog.hpp"
#include "common/message/client_info.hpp"
#include "common/message/hello.hpp"
#include "common/message/time.hpp"
#include "common/snap_exception.hpp"
#include "time_provider.hpp"
// standard headers
#include
#include
#include
#include
using namespace std;
using namespace player;
static constexpr auto LOG_TAG = "Controller";
static constexpr auto TIME_SYNC_INTERVAL = 1s;
Controller::Controller(boost::asio::io_context& io_context, const ClientSettings& settings) //, std::unique_ptr meta)
: io_context_(io_context), timer_(io_context), settings_(settings), stream_(nullptr), decoder_(nullptr), player_(nullptr),
serverSettings_(nullptr) // meta_(std::move(meta)),
{
}
template
std::unique_ptr Controller::createPlayer(ClientSettings::Player& settings, const std::string& player_name)
{
if (settings.player_name.empty() || settings.player_name == player_name)
{
settings.player_name = player_name;
return make_unique(io_context_, settings, stream_);
}
return nullptr;
}
std::vector Controller::getSupportedPlayerNames()
{
std::vector result;
#ifdef HAS_ALSA
result.emplace_back(player::ALSA);
#endif
#ifdef HAS_PULSE
result.emplace_back(player::PULSE);
#endif
#ifdef HAS_OBOE
result.emplace_back(player::OBOE);
#endif
#ifdef HAS_OPENSL
result.emplace_back(player::OPENSL);
#endif
#ifdef HAS_COREAUDIO
result.emplace_back(player::COREAUDIO);
#endif
#ifdef HAS_WASAPI
result.emplace_back(player::WASAPI);
#endif
result.emplace_back(player::FILE);
return result;
}
void Controller::getNextMessage()
{
clientConnection_->getNextMessage(
[this](const boost::system::error_code& ec, std::unique_ptr response)
{
if (ec)
{
reconnect();
return;
}
if (!response)
{
return getNextMessage();
}
if (response->type == message_type::kWireChunk)
{
if (stream_ && decoder_)
{
// execute on the io_context to do the (costly) decoding on another thread (if more than one thread is used)
// boost::asio::post(io_context_, [this, response = std::move(response)]() mutable {
auto pcmChunk = msg::message_cast(std::move(response));
pcmChunk->format = sampleFormat_;
// LOG(TRACE, LOG_TAG) << "chunk: " << pcmChunk->payloadSize << ", sampleFormat: " << sampleFormat_.toString() << "\n";
if (decoder_->decode(pcmChunk.get()))
{
// LOG(TRACE, LOG_TAG) << ", decoded: " << pcmChunk->payloadSize << ", Duration: " << pcmChunk->durationMs() << ", sec: " <<
// pcmChunk->timestamp.sec << ", usec: " << pcmChunk->timestamp.usec / 1000 << ", type: " << pcmChunk->type << "\n";
stream_->addChunk(std::move(pcmChunk));
}
// });
}
}
else if (response->type == message_type::kServerSettings)
{
serverSettings_ = msg::message_cast(std::move(response));
LOG(INFO, LOG_TAG) << "ServerSettings - buffer: " << serverSettings_->getBufferMs() << ", latency: " << serverSettings_->getLatency()
<< ", volume: " << serverSettings_->getVolume() << ", muted: " << serverSettings_->isMuted() << "\n";
if (stream_ && player_)
{
player_->setVolume({serverSettings_->getVolume() / 100., serverSettings_->isMuted()});
stream_->setBufferLen(std::max(0, serverSettings_->getBufferMs() - serverSettings_->getLatency() - settings_.player.latency));
}
}
else if (response->type == message_type::kCodecHeader)
{
headerChunk_ = msg::message_cast(std::move(response));
decoder_.reset(nullptr);
stream_ = nullptr;
player_.reset(nullptr);
if (headerChunk_->codec == "pcm")
decoder_ = make_unique();
#if defined(HAS_OGG) && (defined(HAS_TREMOR) || defined(HAS_VORBIS))
else if (headerChunk_->codec == "ogg")
decoder_ = make_unique();
#endif
#if defined(HAS_FLAC)
else if (headerChunk_->codec == "flac")
decoder_ = make_unique();
#endif
#if defined(HAS_OPUS)
else if (headerChunk_->codec == "opus")
decoder_ = make_unique();
#endif
else if (headerChunk_->codec == "null")
decoder_ = make_unique();
else
throw SnapException("codec not supported: \"" + headerChunk_->codec + "\"");
sampleFormat_ = decoder_->setHeader(headerChunk_.get());
LOG(INFO, LOG_TAG) << "Codec: " << headerChunk_->codec << ", sampleformat: " << sampleFormat_.toString() << "\n";
stream_ = make_shared(sampleFormat_, settings_.player.sample_format);
stream_->setBufferLen(std::max(0, serverSettings_->getBufferMs() - serverSettings_->getLatency() - settings_.player.latency));
#ifdef HAS_ALSA
if (!player_)
player_ = createPlayer(settings_.player, player::ALSA);
#endif
#ifdef HAS_PULSE
if (!player_)
player_ = createPlayer(settings_.player, player::PULSE);
#endif
#ifdef HAS_OBOE
if (!player_)
player_ = createPlayer(settings_.player, player::OBOE);
#endif
#ifdef HAS_OPENSL
if (!player_)
player_ = createPlayer(settings_.player, player::OPENSL);
#endif
#ifdef HAS_COREAUDIO
if (!player_)
player_ = createPlayer(settings_.player, player::COREAUDIO);
#endif
#ifdef HAS_WASAPI
if (!player_)
player_ = createPlayer(settings_.player, player::WASAPI);
#endif
if (!player_ && (settings_.player.player_name == player::FILE))
player_ = createPlayer(settings_.player, player::FILE);
if (!player_)
throw SnapException("No audio player support" + (settings_.player.player_name.empty() ? "" : " for: " + settings_.player.player_name));
player_->setVolumeCallback(
[this](const Player::Volume& volume)
{
// Cache the last volume and check if it really changed in the player's volume callback
static Player::Volume last_volume{-1, true};
if (volume != last_volume)
{
last_volume = volume;
auto info = std::make_shared();
info->setVolume(static_cast(volume.volume * 100.));
info->setMuted(volume.mute);
clientConnection_->send(info,
[this](const boost::system::error_code& ec)
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to send client info, error: " << ec.message() << "\n";
reconnect();
return;
}
});
}
});
player_->start();
// Don't change the initial hardware mixer volume on the user's device.
// The player class will send the device's volume to the server instead
// if (settings_.player.mixer.mode != ClientSettings::Mixer::Mode::hardware)
// {
player_->setVolume({serverSettings_->getVolume() / 100., serverSettings_->isMuted()});
// }
}
else
{
LOG(WARNING, LOG_TAG) << "Unexpected message received, type: " << response->type << "\n";
}
getNextMessage();
});
}
void Controller::sendTimeSyncMessage(int quick_syncs)
{
auto timeReq = std::make_shared();
clientConnection_->sendRequest(timeReq, 2s,
[this, quick_syncs](const boost::system::error_code& ec, const std::unique_ptr& response) mutable
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Time sync request failed: " << ec.message() << "\n";
reconnect();
return;
}
else
{
TimeProvider::getInstance().setDiff(response->latency, response->received - response->sent);
}
std::chrono::microseconds next = TIME_SYNC_INTERVAL;
if (quick_syncs > 0)
{
if (--quick_syncs == 0)
LOG(INFO, LOG_TAG) << "diff to server [ms]: "
<< static_cast(TimeProvider::getInstance().getDiffToServer().count()) / 1000.f << "\n";
next = 100us;
}
timer_.expires_after(next);
timer_.async_wait(
[this, quick_syncs](const boost::system::error_code& ec)
{
if (!ec)
{
sendTimeSyncMessage(quick_syncs);
}
});
});
}
void Controller::browseMdns(const MdnsHandler& handler)
{
#if defined(HAS_AVAHI) || defined(HAS_BONJOUR)
try
{
BrowseZeroConf browser;
mDNSResult avahiResult;
if (browser.browse("_snapcast._tcp", avahiResult, 1000))
{
string host = avahiResult.ip;
uint16_t port = avahiResult.port;
if (avahiResult.ip_version == IPVersion::IPv6)
host += "%" + cpt::to_string(avahiResult.iface_idx);
handler({}, host, port);
return;
}
}
catch (const std::exception& e)
{
LOG(ERROR, LOG_TAG) << "Exception: " << e.what() << std::endl;
}
timer_.expires_after(500ms);
timer_.async_wait(
[this, handler](const boost::system::error_code& ec)
{
if (!ec)
{
browseMdns(handler);
}
else
{
handler(ec, "", 0);
}
});
#else
handler(boost::asio::error::operation_not_supported, "", 0);
#endif
}
void Controller::start()
{
if (settings_.server.host.empty())
{
browseMdns(
[this](const boost::system::error_code& ec, const std::string& host, uint16_t port)
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to browse MDNS, error: " << ec.message() << "\n";
}
else
{
settings_.server.host = host;
settings_.server.port = port;
LOG(INFO, LOG_TAG) << "Found server " << settings_.server.host << ":" << settings_.server.port << "\n";
clientConnection_ = make_unique(io_context_, settings_.server);
worker();
}
});
}
else
{
clientConnection_ = make_unique(io_context_, settings_.server);
worker();
}
}
// void Controller::stop()
// {
// LOG(DEBUG, LOG_TAG) << "Stopping\n";
// timer_.cancel();
// }
void Controller::reconnect()
{
timer_.cancel();
clientConnection_->disconnect();
player_.reset();
stream_.reset();
decoder_.reset();
timer_.expires_after(1s);
timer_.async_wait(
[this](const boost::system::error_code& ec)
{
if (!ec)
{
worker();
}
});
}
void Controller::worker()
{
clientConnection_->connect(
[this](const boost::system::error_code& ec)
{
if (!ec)
{
// LOG(INFO, LOG_TAG) << "Connected!\n";
string macAddress = clientConnection_->getMacAddress();
if (settings_.host_id.empty())
settings_.host_id = ::getHostId(macAddress);
// Say hello to the server
auto hello = std::make_shared(macAddress, settings_.host_id, settings_.instance);
clientConnection_->sendRequest(
hello, 2s,
[this](const boost::system::error_code& ec, std::unique_ptr response) mutable
{
if (ec)
{
LOG(ERROR, LOG_TAG) << "Failed to send hello request, error: " << ec.message() << "\n";
reconnect();
return;
}
else
{
serverSettings_ = std::move(response);
LOG(INFO, LOG_TAG) << "ServerSettings - buffer: " << serverSettings_->getBufferMs() << ", latency: " << serverSettings_->getLatency()
<< ", volume: " << serverSettings_->getVolume() << ", muted: " << serverSettings_->isMuted() << "\n";
}
});
// Do initial time sync with the server
sendTimeSyncMessage(50);
// Start receiver loop
getNextMessage();
}
else
{
LOG(ERROR, LOG_TAG) << "Error: " << ec.message() << "\n";
reconnect();
}
});
}
snapcast-0.28.0/client/controller.hpp 0000664 0000000 0000000 00000004724 14610511116 0017572 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "client_connection.hpp"
#include "client_settings.hpp"
#include "common/message/server_settings.hpp"
#include "decoder/decoder.hpp"
#include "player/player.hpp"
#include "stream.hpp"
// 3rd party headers
// standard headers
using namespace std::chrono_literals;
/// Forwards PCM data to the audio player
/**
* Sets up a connection to the server (using ClientConnection)
* Sets up the audio decoder and player.
* Decodes audio (message_type::kWireChunk) and feeds PCM to the audio stream buffer
* Does timesync with the server
*/
class Controller
{
public:
Controller(boost::asio::io_context& io_context, const ClientSettings& settings); //, std::unique_ptr meta);
void start();
// void stop();
static std::vector getSupportedPlayerNames();
private:
using MdnsHandler = std::function;
void worker();
void reconnect();
void browseMdns(const MdnsHandler& handler);
template
std::unique_ptr createPlayer(ClientSettings::Player& settings, const std::string& player_name);
void getNextMessage();
void sendTimeSyncMessage(int quick_syncs);
boost::asio::io_context& io_context_;
boost::asio::steady_timer timer_;
ClientSettings settings_;
SampleFormat sampleFormat_;
std::unique_ptr clientConnection_;
std::shared_ptr stream_;
std::unique_ptr decoder_;
std::unique_ptr player_;
// std::unique_ptr meta_;
std::unique_ptr serverSettings_;
std::unique_ptr headerChunk_;
};
snapcast-0.28.0/client/decoder/ 0000775 0000000 0000000 00000000000 14610511116 0016274 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/client/decoder/decoder.hpp 0000664 0000000 0000000 00000002314 14610511116 0020412 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2023 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "common/message/codec_header.hpp"
#include "common/message/pcm_chunk.hpp"
#include "common/sample_format.hpp"
// 3rd party headers
// standard headers
#include
namespace decoder
{
class Decoder
{
public:
Decoder(){};
virtual ~Decoder() = default;
virtual bool decode(msg::PcmChunk* chunk) = 0;
virtual SampleFormat setHeader(msg::CodecHeader* chunk) = 0;
protected:
std::mutex mutex_;
};
} // namespace decoder
snapcast-0.28.0/client/decoder/flac_decoder.cpp 0000664 0000000 0000000 00000021143 14610511116 0021373 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "flac_decoder.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/endian.hpp"
#include "common/snap_exception.hpp"
// standard headers
#include
#include
using namespace std;
static constexpr auto LOG_TAG = "FlacDecoder";
namespace decoder
{
namespace callback
{
FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[],
void* client_data);
void metadata_callback(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data);
void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
} // namespace callback
namespace
{
msg::CodecHeader* flacHeader = nullptr;
msg::PcmChunk* flacChunk = nullptr;
msg::PcmChunk* pcmChunk = nullptr;
SampleFormat sampleFormat;
FLAC__StreamDecoder* decoder = nullptr;
} // namespace
FlacDecoder::FlacDecoder() : Decoder(), lastError_(nullptr)
{
flacChunk = new msg::PcmChunk();
}
FlacDecoder::~FlacDecoder()
{
std::lock_guard lock(mutex_);
FLAC__stream_decoder_delete(decoder);
delete flacChunk;
}
bool FlacDecoder::decode(msg::PcmChunk* chunk)
{
std::lock_guard lock(mutex_);
cacheInfo_.reset();
pcmChunk = chunk;
flacChunk->payload = static_cast(realloc(flacChunk->payload, chunk->payloadSize));
memcpy(flacChunk->payload, chunk->payload, chunk->payloadSize);
flacChunk->payloadSize = chunk->payloadSize;
pcmChunk->payload = static_cast(realloc(pcmChunk->payload, 0));
pcmChunk->payloadSize = 0;
while (flacChunk->payloadSize > 0)
{
if (FLAC__stream_decoder_process_single(decoder) == 0)
{
return false;
}
if (lastError_)
{
LOG(ERROR, LOG_TAG) << "FLAC decode error: " << FLAC__StreamDecoderErrorStatusString[*lastError_] << "\n";
lastError_ = nullptr;
return false;
}
}
if ((cacheInfo_.cachedBlocks_ > 0) && (cacheInfo_.sampleRate_ != 0))
{
double diffMs = static_cast(cacheInfo_.cachedBlocks_) / (static_cast(cacheInfo_.sampleRate_) / 1000.);
auto us = static_cast(diffMs * 1000.);
tv diff(static_cast(us / 1000000), static_cast(us % 1000000));
LOG(TRACE, LOG_TAG) << "Cached: " << cacheInfo_.cachedBlocks_ << ", " << diffMs << "ms, " << diff.sec << "s, " << diff.usec << "us\n";
chunk->timestamp = chunk->timestamp - diff;
}
return true;
}
SampleFormat FlacDecoder::setHeader(msg::CodecHeader* chunk)
{
flacHeader = chunk;
FLAC__StreamDecoderInitStatus init_status;
if ((decoder = FLAC__stream_decoder_new()) == nullptr)
throw SnapException("ERROR: allocating decoder");
// (void)FLAC__stream_decoder_set_md5_checking(decoder, true);
init_status = FLAC__stream_decoder_init_stream(decoder, callback::read_callback, nullptr, nullptr, nullptr, nullptr, callback::write_callback,
callback::metadata_callback, callback::error_callback, this);
if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
throw SnapException("ERROR: initializing decoder: " + string(FLAC__StreamDecoderInitStatusString[init_status]));
FLAC__stream_decoder_process_until_end_of_metadata(decoder);
if (sampleFormat.rate() == 0)
throw SnapException("Sample format not found");
return sampleFormat;
}
namespace callback
{
FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder* /*decoder*/, FLAC__byte buffer[], size_t* bytes, void* client_data)
{
if (flacHeader != nullptr)
{
*bytes = flacHeader->payloadSize;
memcpy(buffer, flacHeader->payload, *bytes);
flacHeader = nullptr;
}
else if (flacChunk != nullptr)
{
// cerr << "read_callback: " << *bytes << ", avail: " << flacChunk->payloadSize << "\n";
static_cast(client_data)->cacheInfo_.isCachedChunk_ = false;
if (*bytes > flacChunk->payloadSize)
*bytes = flacChunk->payloadSize;
// if (*bytes == 0)
// return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
memcpy(buffer, flacChunk->payload, *bytes);
memmove(flacChunk->payload, flacChunk->payload + *bytes, flacChunk->payloadSize - *bytes);
flacChunk->payloadSize = flacChunk->payloadSize - static_cast(*bytes);
flacChunk->payload = static_cast(realloc(flacChunk->payload, flacChunk->payloadSize));
}
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* /*decoder*/, const FLAC__Frame* frame, const FLAC__int32* const buffer[],
void* client_data)
{
if (pcmChunk != nullptr)
{
size_t bytes = frame->header.blocksize * sampleFormat.frameSize();
auto* flacDecoder = static_cast(client_data);
if (flacDecoder->cacheInfo_.isCachedChunk_)
flacDecoder->cacheInfo_.cachedBlocks_ += frame->header.blocksize;
pcmChunk->payload = static_cast(realloc(pcmChunk->payload, pcmChunk->payloadSize + bytes));
for (size_t channel = 0; channel < sampleFormat.channels(); ++channel)
{
if (buffer[channel] == nullptr)
{
LOG(ERROR, LOG_TAG) << "ERROR: buffer[" << channel << "] is NULL\n";
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
if (sampleFormat.sampleSize() == 1)
{
auto* chunkBuffer = reinterpret_cast(pcmChunk->payload + pcmChunk->payloadSize);
for (size_t i = 0; i < frame->header.blocksize; i++)
chunkBuffer[sampleFormat.channels() * i + channel] = static_cast(buffer[channel][i]);
}
else if (sampleFormat.sampleSize() == 2)
{
auto* chunkBuffer = reinterpret_cast(pcmChunk->payload + pcmChunk->payloadSize);
for (size_t i = 0; i < frame->header.blocksize; i++)
chunkBuffer[sampleFormat.channels() * i + channel] = SWAP_16((int16_t)(buffer[channel][i]));
}
else if (sampleFormat.sampleSize() == 4)
{
auto* chunkBuffer = reinterpret_cast(pcmChunk->payload + pcmChunk->payloadSize);
for (size_t i = 0; i < frame->header.blocksize; i++)
chunkBuffer[sampleFormat.channels() * i + channel] = SWAP_32((int32_t)(buffer[channel][i]));
}
}
pcmChunk->payloadSize += static_cast(bytes);
}
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
void metadata_callback(const FLAC__StreamDecoder* /*decoder*/, const FLAC__StreamMetadata* metadata, void* client_data)
{
/* print some stats */
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
{
static_cast(client_data)->cacheInfo_.sampleRate_ = metadata->data.stream_info.sample_rate;
sampleFormat.setFormat(metadata->data.stream_info.sample_rate, static_cast(metadata->data.stream_info.bits_per_sample),
static_cast(metadata->data.stream_info.channels));
}
}
void error_callback(const FLAC__StreamDecoder* /*decoder*/, FLAC__StreamDecoderErrorStatus status, void* client_data)
{
LOG(ERROR, LOG_TAG) << "Got error callback: " << FLAC__StreamDecoderErrorStatusString[status] << "\n";
static_cast(client_data)->lastError_ = std::make_unique(status);
}
} // namespace callback
} // namespace decoder
snapcast-0.28.0/client/decoder/flac_decoder.hpp 0000664 0000000 0000000 00000002713 14610511116 0021402 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "decoder.hpp"
// 3rd party headers
#include
// standard headers
#include
namespace decoder
{
struct CacheInfo
{
CacheInfo() : sampleRate_(0)
{
reset();
}
void reset()
{
isCachedChunk_ = true;
cachedBlocks_ = 0;
}
bool isCachedChunk_;
size_t cachedBlocks_;
size_t sampleRate_;
};
class FlacDecoder : public Decoder
{
public:
FlacDecoder();
~FlacDecoder() override;
bool decode(msg::PcmChunk* chunk) override;
SampleFormat setHeader(msg::CodecHeader* chunk) override;
CacheInfo cacheInfo_;
std::unique_ptr lastError_;
};
} // namespace decoder
snapcast-0.28.0/client/decoder/null_decoder.cpp 0000664 0000000 0000000 00000002174 14610511116 0021443 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "null_decoder.hpp"
// local headers
// 3rd party headers
// standard headers
namespace decoder
{
NullDecoder::NullDecoder() : Decoder()
{
}
bool NullDecoder::decode(msg::PcmChunk* /*chunk*/)
{
return true;
}
SampleFormat NullDecoder::setHeader(msg::CodecHeader* chunk)
{
std::ignore = chunk;
return {48000, 16, 2};
}
} // namespace decoder
snapcast-0.28.0/client/decoder/null_decoder.hpp 0000664 0000000 0000000 00000001773 14610511116 0021454 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2023 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "decoder.hpp"
namespace decoder
{
class NullDecoder : public Decoder
{
public:
NullDecoder();
bool decode(msg::PcmChunk* chunk) override;
SampleFormat setHeader(msg::CodecHeader* chunk) override;
};
} // namespace decoder
snapcast-0.28.0/client/decoder/ogg_decoder.cpp 0000664 0000000 0000000 00000021455 14610511116 0021250 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "ogg_decoder.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/endian.hpp"
#include "common/snap_exception.hpp"
// 3rd party headers
// standard headers
#ifndef HAS_TREMOR
#include // floor
#endif
#include
#include
using namespace std;
static constexpr auto LOG_TAG = "OggDecoder";
namespace decoder
{
OggDecoder::OggDecoder() : Decoder()
{
ogg_sync_init(&oy); /* Now we can read pages */
}
OggDecoder::~OggDecoder()
{
std::lock_guard lock(mutex_);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
ogg_stream_clear(&os);
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi); /* must be called last */
ogg_sync_clear(&oy);
}
bool OggDecoder::decode(msg::PcmChunk* chunk)
{
std::lock_guard lock(mutex_);
/* grab some data at the head of the stream. We want the first page
(which is guaranteed to be small and only contain the Vorbis
stream initial header) We need the first page to get the stream
serialno. */
int size = chunk->payloadSize;
char* buffer = ogg_sync_buffer(&oy, size);
memcpy(buffer, chunk->payload, size);
ogg_sync_wrote(&oy, size);
chunk->payloadSize = 0;
/* The rest is just a straight decode loop until end of stream */
// while(!eos){
while (true)
{
int result = ogg_sync_pageout(&oy, &og);
if (result == 0)
break; /* need more data */
if (result < 0)
{
/* missing or corrupt data at this page position */
LOG(ERROR, LOG_TAG) << "Corrupt or missing data in bitstream; continuing...\n";
continue;
}
ogg_stream_pagein(&os, &og); /* can safely ignore errors at this point */
while (true)
{
result = ogg_stream_packetout(&os, &op);
if (result == 0)
break; /* need more data */
if (result < 0)
continue; /* missing or corrupt data at this page position */
/* no reason to complain; already complained above */
/* we have a packet. Decode it */
#ifdef HAS_TREMOR
ogg_int32_t** pcm;
#else
float** pcm;
#endif
int samples;
if (vorbis_synthesis(&vb, &op) == 0) /* test for success! */
vorbis_synthesis_blockin(&vd, &vb);
/*
**pcm is a multichannel float vector. In stereo, for
example, pcm[0] is left, and pcm[1] is right. samples is
the size of each channel. Convert the float values
(-1.<=range<=1.) to whatever PCM format and write it out */
while ((samples = vorbis_synthesis_pcmout(&vd, &pcm)) > 0)
{
uint32_t bytes = sampleFormat_.sampleSize() * vi.channels * samples;
chunk->payload = static_cast(realloc(chunk->payload, chunk->payloadSize + bytes));
for (int channel = 0; channel < vi.channels; ++channel)
{
if (sampleFormat_.sampleSize() == 1)
{
auto* chunkBuffer = reinterpret_cast(chunk->payload + chunk->payloadSize);
for (int i = 0; i < samples; i++)
{
int8_t& val = chunkBuffer[sampleFormat_.channels() * i + channel];
#ifdef HAS_TREMOR
val = clip(pcm[channel][i], INT8_MIN, INT8_MAX);
#else
val = clip(floor(pcm[channel][i] * 127.f + .5f), INT8_MIN, INT8_MAX);
#endif
}
}
else if (sampleFormat_.sampleSize() == 2)
{
auto* chunkBuffer = reinterpret_cast(chunk->payload + chunk->payloadSize);
for (int i = 0; i < samples; i++)
{
int16_t& val = chunkBuffer[sampleFormat_.channels() * i + channel];
#ifdef HAS_TREMOR
val = SWAP_16(clip(pcm[channel][i] >> 9, INT16_MIN, INT16_MAX));
#else
val = SWAP_16(clip(floor(pcm[channel][i] * 32767.f + .5f), INT16_MIN, INT16_MAX));
#endif
}
}
else if (sampleFormat_.sampleSize() == 4)
{
auto* chunkBuffer = reinterpret_cast(chunk->payload + chunk->payloadSize);
for (int i = 0; i < samples; i++)
{
int32_t& val = chunkBuffer[sampleFormat_.channels() * i + channel];
#ifdef HAS_TREMOR
val = SWAP_32(clip(pcm[channel][i] << 7, INT32_MIN, INT32_MAX));
#else
val = SWAP_32(clip(floor(pcm[channel][i] * 2147483647.f + .5f), INT32_MIN, INT32_MAX));
#endif
}
}
}
chunk->payloadSize += bytes;
vorbis_synthesis_read(&vd, samples);
}
}
}
return true;
}
SampleFormat OggDecoder::setHeader(msg::CodecHeader* chunk)
{
int size = chunk->payloadSize;
char* buffer = ogg_sync_buffer(&oy, size);
memcpy(buffer, chunk->payload, size);
ogg_sync_wrote(&oy, size);
if (ogg_sync_pageout(&oy, &og) != 1)
throw SnapException("Input does not appear to be an Ogg bitstream");
ogg_stream_init(&os, ogg_page_serialno(&og));
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
if (ogg_stream_pagein(&os, &og) < 0)
throw SnapException("Error reading first page of Ogg bitstream data");
if (ogg_stream_packetout(&os, &op) != 1)
throw SnapException("Error reading initial header packet");
if (vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
throw SnapException("This Ogg bitstream does not contain Vorbis audio data");
int i(0);
while (i < 2)
{
while (i < 2)
{
int result = ogg_sync_pageout(&oy, &og);
if (result == 0)
break; /* Need more data */
/* Don't complain about missing or corrupt data yet. We'll
catch it at the packet output phase */
if (result == 1)
{
ogg_stream_pagein(&os, &og); /* we can ignore any errors here as they'll also become apparent at packetout */
while (i < 2)
{
result = ogg_stream_packetout(&os, &op);
if (result == 0)
break;
/// Uh oh; data at some point was corrupted or missing!
/// We can't tolerate that in a header. Die. */
if (result < 0)
throw SnapException("Corrupt secondary header. Exiting.");
result = vorbis_synthesis_headerin(&vi, &vc, &op);
if (result < 0)
throw SnapException("Corrupt secondary header. Exiting.");
i++;
}
}
}
}
/// OK, got and parsed all three headers. Initialize the Vorbis packet->PCM decoder.
if (vorbis_synthesis_init(&vd, &vi) == 0)
vorbis_block_init(&vd, &vb);
/// central decode state
/// local state for most of the decode so multiple block decodes can proceed
/// in parallel. We could init multiple vorbis_block structures for vd here
sampleFormat_.setFormat(vi.rate, 16, static_cast(vi.channels));
/* Throw the comments plus a few lines about the bitstream we're decoding */
char** ptr = vc.user_comments;
while (*ptr != nullptr)
{
std::string comment(*ptr);
if (comment.find("SAMPLE_FORMAT=") == 0)
sampleFormat_.setFormat(comment.substr(comment.find('=') + 1));
LOG(INFO, LOG_TAG) << "comment: " << comment << "\n";
;
++ptr;
}
LOG(INFO, LOG_TAG) << "Encoded by: " << vc.vendor << "\n";
return sampleFormat_;
}
} // namespace decoder
snapcast-0.28.0/client/decoder/ogg_decoder.hpp 0000664 0000000 0000000 00000004236 14610511116 0021253 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "decoder.hpp"
// 3rd party headers
#ifdef HAS_TREMOR
#include
#else
#include
#endif
#include
namespace decoder
{
class OggDecoder : public Decoder
{
public:
OggDecoder();
~OggDecoder() override;
bool decode(msg::PcmChunk* chunk) override;
SampleFormat setHeader(msg::CodecHeader* chunk) override;
private:
bool decodePayload(msg::PcmChunk* chunk);
template
T clip(const IN_TYPE& value, const T& lower, const T& upper) const
{
auto val = static_cast(value);
if (val > upper)
return upper;
if (val < lower)
return lower;
return static_cast(value);
}
ogg_sync_state oy; /// sync and verify incoming physical bitstream
ogg_stream_state os; /// take physical pages, weld into a logical stream of packets
ogg_page og; /// one Ogg bitstream page. Vorbis packets are inside
ogg_packet op; /// one raw packet of data for decode
vorbis_info vi; /// struct that stores all the static vorbis bitstream settings
vorbis_comment vc; /// struct that stores all the bitstream user comments
vorbis_dsp_state vd; /// central working state for the packet->PCM decoder
vorbis_block vb; /// local working space for packet->PCM decode
SampleFormat sampleFormat_;
};
} // namespace decoder
snapcast-0.28.0/client/decoder/opus_decoder.cpp 0000664 0000000 0000000 00000010377 14610511116 0021463 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2015 Hannes Ellinger
Copyright (C) 2016-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "opus_decoder.hpp"
// local headers
#include "common/aixlog.hpp"
#include "common/snap_exception.hpp"
namespace decoder
{
#define ID_OPUS 0x4F505553
/// int: Number of samples per channel in the input signal.
/// This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the
/// permitted values are 120, 240, 480, 960, 1920, and 2880.
/// Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.
static constexpr int const_max_frame_size = 2880;
static constexpr auto LOG_TAG = "OpusDecoder";
OpusDecoder::OpusDecoder() : Decoder(), dec_(nullptr)
{
pcm_.resize(120);
}
OpusDecoder::~OpusDecoder()
{
if (dec_ != nullptr)
opus_decoder_destroy(dec_);
}
bool OpusDecoder::decode(msg::PcmChunk* chunk)
{
int decoded_frames = 0;
while ((decoded_frames = opus_decode(dec_, reinterpret_cast(chunk->payload), chunk->payloadSize, pcm_.data(),
static_cast(pcm_.size()) / sample_format_.channels(), 0)) == OPUS_BUFFER_TOO_SMALL)
{
if (pcm_.size() < const_max_frame_size * sample_format_.channels())
{
pcm_.resize(pcm_.size() * 2);
LOG(DEBUG, LOG_TAG) << "OPUS encoding buffer too small, resizing to " << pcm_.size() / sample_format_.channels() << " samples per channel\n";
}
else
break;
}
if (decoded_frames < 0)
{
LOG(ERROR, LOG_TAG) << "Failed to decode chunk: " << opus_strerror(decoded_frames) << ", IN size: " << chunk->payloadSize
<< ", OUT size: " << pcm_.size() << '\n';
return false;
}
else
{
LOG(TRACE, LOG_TAG) << "Decode chunk: " << decoded_frames << " frames, size: " << chunk->payloadSize
<< " bytes, decoded: " << decoded_frames * sample_format_.frameSize() << " bytes\n";
// copy encoded data to chunk
chunk->payloadSize = decoded_frames * sample_format_.frameSize(); // decoded_frames * sample_format_.channels() * sizeof(opus_int16);
chunk->payload = static_cast(realloc(chunk->payload, chunk->payloadSize));
memcpy(chunk->payload, reinterpret_cast(pcm_.data()), chunk->payloadSize);
return true;
}
}
SampleFormat OpusDecoder::setHeader(msg::CodecHeader* chunk)
{
// decode the opus pseudo header
if (chunk->payloadSize < 12)
throw SnapException("OPUS header too small");
// decode the "opus id" magic number, this is our constant part that must match
uint32_t id_opus;
memcpy(&id_opus, chunk->payload, sizeof(id_opus));
if (SWAP_32(id_opus) != ID_OPUS)
throw SnapException("Not an Opus pseudo header");
// decode the sampleformat
uint32_t rate;
memcpy(&rate, chunk->payload + 4, sizeof(rate));
uint16_t bits;
memcpy(&bits, chunk->payload + 8, sizeof(bits));
uint16_t channels;
memcpy(&channels, chunk->payload + 10, sizeof(channels));
sample_format_.setFormat(SWAP_32(rate), SWAP_16(bits), SWAP_16(channels));
LOG(DEBUG, LOG_TAG) << "Opus sampleformat: " << sample_format_.toString() << "\n";
// create the decoder
int error;
dec_ = opus_decoder_create(sample_format_.rate(), sample_format_.channels(), &error);
if (error != 0)
throw SnapException("Failed to initialize Opus decoder: " + std::string(opus_strerror(error)));
return sample_format_;
}
} // namespace decoder
snapcast-0.28.0/client/decoder/opus_decoder.hpp 0000664 0000000 0000000 00000002455 14610511116 0021466 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2015 Hannes Ellinger
Copyright (C) 2016-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "decoder/decoder.hpp"
// 3rd party headers
#include
// standard headers
#include
namespace decoder
{
class OpusDecoder : public Decoder
{
public:
OpusDecoder();
~OpusDecoder();
bool decode(msg::PcmChunk* chunk) override;
SampleFormat setHeader(msg::CodecHeader* chunk) override;
private:
::OpusDecoder* dec_;
std::vector pcm_;
SampleFormat sample_format_;
};
} // namespace decoder
snapcast-0.28.0/client/decoder/pcm_decoder.cpp 0000664 0000000 0000000 00000007072 14610511116 0021252 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
// prototype/interface header file
#include "pcm_decoder.hpp"
// local headers
#include "common/endian.hpp"
#include "common/snap_exception.hpp"
namespace decoder
{
static constexpr auto ID_RIFF = 0x46464952;
static constexpr auto ID_WAVE = 0x45564157;
static constexpr auto ID_FMT = 0x20746d66;
static constexpr auto ID_DATA = 0x61746164;
struct riff_wave_header
{
uint32_t riff_id;
uint32_t riff_sz;
uint32_t wave_id;
};
struct chunk_header
{
uint32_t id;
uint32_t sz;
};
struct chunk_fmt
{
uint16_t audio_format;
uint16_t num_channels;
uint32_t sample_rate;
uint32_t byte_rate;
uint16_t block_align;
uint16_t bits_per_sample;
};
PcmDecoder::PcmDecoder() : Decoder()
{
}
bool PcmDecoder::decode(msg::PcmChunk* /*chunk*/)
{
return true;
}
SampleFormat PcmDecoder::setHeader(msg::CodecHeader* chunk)
{
if (chunk->payloadSize < 44)
throw SnapException("PCM header too small");
struct riff_wave_header riff_wave_header;
struct chunk_header chunk_header;
struct chunk_fmt chunk_fmt;
chunk_fmt.sample_rate = SWAP_32(0);
chunk_fmt.bits_per_sample = SWAP_16(0);
chunk_fmt.num_channels = SWAP_16(0);
size_t pos(0);
memcpy(&riff_wave_header, chunk->payload + pos, sizeof(riff_wave_header));
pos += sizeof(riff_wave_header);
if ((SWAP_32(riff_wave_header.riff_id) != ID_RIFF) || (SWAP_32(riff_wave_header.wave_id) != ID_WAVE))
throw SnapException("Not a riff/wave header");
bool moreChunks(true);
do
{
if (pos + sizeof(chunk_header) > chunk->payloadSize)
throw SnapException("riff/wave header incomplete");
memcpy(&chunk_header, chunk->payload + pos, sizeof(chunk_header));
pos += sizeof(chunk_header);
switch (SWAP_32(chunk_header.id))
{
case ID_FMT:
if (pos + sizeof(chunk_fmt) > chunk->payloadSize)
throw SnapException("riff/wave header incomplete");
memcpy(&chunk_fmt, chunk->payload + pos, sizeof(chunk_fmt));
pos += sizeof(chunk_fmt);
/// If the format header is larger, skip the rest
if (SWAP_32(chunk_header.sz) > sizeof(chunk_fmt))
pos += (SWAP_32(chunk_header.sz) - sizeof(chunk_fmt));
break;
case ID_DATA:
/// Stop looking for chunks
moreChunks = false;
break;
default:
/// Unknown chunk, skip bytes
pos += SWAP_32(chunk_header.sz);
}
} while (moreChunks);
if (SWAP_32(chunk_fmt.sample_rate) == 0)
throw SnapException("Sample format not found");
SampleFormat sampleFormat(SWAP_32(chunk_fmt.sample_rate), SWAP_16(chunk_fmt.bits_per_sample), SWAP_16(chunk_fmt.num_channels));
return sampleFormat;
}
} // namespace decoder
snapcast-0.28.0/client/decoder/pcm_decoder.hpp 0000664 0000000 0000000 00000001771 14610511116 0021257 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// local headers
#include "decoder.hpp"
namespace decoder
{
class PcmDecoder : public Decoder
{
public:
PcmDecoder();
bool decode(msg::PcmChunk* chunk) override;
SampleFormat setHeader(msg::CodecHeader* chunk) override;
};
} // namespace decoder
snapcast-0.28.0/client/double_buffer.hpp 0000664 0000000 0000000 00000007322 14610511116 0020207 0 ustar 00root root 0000000 0000000 /***
This file is part of snapcast
Copyright (C) 2014-2024 Johannes Pohl
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
***/
#pragma once
// standard headers
#include
#include
#include
#include
#include
/// Size limited queue
/**
* Size limited queue with basic statistic functions:
* median, mean, percentile
*/
template
class DoubleBuffer
{
public:
DoubleBuffer(size_t size = 10) : bufferSize(size)
{
}
inline void add(const T& element)
{
buffer.push_back(element);
if (buffer.size() > bufferSize)
buffer.pop_front();
}
inline void add(T&& element)
{
buffer.push_back(std::move(element));
if (buffer.size() > bufferSize)
buffer.pop_front();
}
/// Median as mean over N values around the median
T median(uint16_t mean = 1) const
{
if (buffer.empty())
return 0;
std::deque tmpBuffer(buffer.begin(), buffer.end());
std::sort(tmpBuffer.begin(), tmpBuffer.end());
if ((mean <= 1) || (tmpBuffer.size() < mean))
return tmpBuffer[tmpBuffer.size() / 2];
else
{
uint16_t low = static_cast(tmpBuffer.size()) / 2;
uint16_t high = low;
low -= mean / 2;
high += mean / 2;
T result((T)0);
for (uint16_t i = low; i <= high; ++i)
{
result += tmpBuffer[i];
}
return result / mean;
}
}
double mean() const
{
if (buffer.empty())
return 0;
double mean = 0.;
for (size_t n = 0; n < buffer.size(); ++n)
mean += (float)buffer[n] / (float)buffer.size();
return mean;
}
T percentile(unsigned int percentile) const
{
if (buffer.empty())
return 0;
std::deque tmpBuffer(buffer.begin(), buffer.end());
std::sort(tmpBuffer.begin(), tmpBuffer.end());
return tmpBuffer[(size_t)((tmpBuffer.size() - 1) * ((float)percentile / (float)100))];
}
template
std::array percentiles(std::array percentiles) const
{
std::array result;
result.fill(0);
if (buffer.empty())
return result;
std::deque tmpBuffer(buffer.begin(), buffer.end());
std::sort(tmpBuffer.begin(), tmpBuffer.end());
for (std::size_t i = 0; i < Size; ++i)
result[i] = tmpBuffer[(size_t)((tmpBuffer.size() - 1) * ((float)percentiles[i] / (float)100))];
return result;
}
inline bool full() const
{
return (buffer.size() == bufferSize);
}
inline void clear()
{
buffer.clear();
}
inline size_t size() const
{
return buffer.size();
}
inline bool empty() const
{
return buffer.empty();
}
void setSize(size_t size)
{
bufferSize = size;
}
const std::deque& getBuffer() const
{
return buffer;
}
private:
size_t bufferSize;
std::deque buffer;
};
snapcast-0.28.0/client/etc/ 0000775 0000000 0000000 00000000000 14610511116 0015442 5 ustar 00root root 0000000 0000000 snapcast-0.28.0/client/etc/snapcast.svg 0000664 0000000 0000000 00000017235 14610511116 0020007 0 ustar 00root root 0000000 0000000
snapcast-0.28.0/client/etc/snapclient.plist 0000664 0000000 0000000 00000000750 14610511116 0020661 0 ustar 00root root 0000000 0000000
Labelde.badaix.snapcast.snapclientProgramArguments/usr/local/bin/snapclient--logsink=systemRunAtLoadKeepAlive