Synchronous multiroom audio player

Overview

Snapcast

Snapcast

Synchronous audio player

Build Status Github Releases Donate

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) or Mopidy.

Overview

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.

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:

Nightly builds

There are debian packages of automated builds for armhf and amd64 available in Actions.
Download and extract the archive for your architecture and follow the debian installation instructions.

Installation from source

Please follow this guide to build Snapcast for

SnapOS

The bravest among you may be interested in SnapOS, a small and fast-booting "just enough" OS to run Snapcast as an appliance.

There is a guide (with the necessary buildfiles) available to build SnapOS, which comes in two flavors:

Please note that there are no pre-built firmware packages available.

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.:

[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: read audio from a named pipe
  • alsa: read audio from an alsa device
  • librespot: launches librespot and reads audio from stdout
  • airplay: launches airplay and read audio from stdout
  • file: read PCM audio from a file
  • process: launches a process and reads audio from stdout
  • tcp: receives audio from a TCP socket, can act as client or server
  • 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=<total buffer size [ms]> (default 80, min 10)
fragments=<number of buffers> (default 4, min 2)
pulse Linux PulseAudio buffer_time=<buffer size [ms]> (default 100, min 10)
server=<PulseAudio server> - default not-set: use the default server
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=<filename> (<filename> = stdout, stderr, null or a filename)
`mode=[w

Parameters are appended to the player name, e.g. --player alsa:buffer_time=100. Use --player <name>:? 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 choosen by index or name. Available PCM devices can be listed with -l or --list

Test

You can test your installation by copying random data into the server's fifo file

sudo 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

Control

Snapcast can be controlled using a JSON-RPC API 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, this WebApp can be reached under http://<snapserver host>:1780.

Snapweb

Android client

There is an Android client snapdroid available in Releases and on Google Play

Snapcast for Android

Contributions

There is also an unofficial WebApp from @atoomic 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 from @unimatrix27 which integrates a Snapcast controller into the FHEM home automation system.

There is a snapcast component for Home Assistant which integrates a Snapcast controller in to the Home Assistant home automation system.

For a web interface in Python, see snapcastr, based on python-snapcast. This interface controls client volume and assigns streams to groups.

Another web interface running on any device is snapcast-websockets-ui, running entirely in the browser, which needs websockify. No configuration needed; features almost all functions; still needs some tuning for the optics.

A web interface called 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, 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 and Mopidy are given, which are base of other audio player solutions, like Volumio or RuneAudio (both MPD) or Pi MusicBox (Mopidy).

The goal is to build the following chain:

audio player software -> snapfifo -> snapserver -> network -> snapclient -> alsa

This guide shows how to configure different players/audio sources to redirect their audio signal into the Snapserver's fifo:

Roadmap

Unordered list of features that should make it into the v1.0

  • Remote control JSON-RPC API to change client latency, volume, zone,...
  • Android client JSON-RPC client and Snapclient
  • Streams Support multiple streams
  • Debian packages prebuild deb packages
  • Endian independent code
  • OpenWrt port Snapclient to OpenWrt
  • Hi-Res audio support (like 96kHz 24bit)
  • Groups support multiple Groups of clients ("Zones")
  • Ports Snapclient for Windows, Mac OS X,...
  • JSON-RPC Possibility to add, remove, rename streams
  • Protocol specification Snapcast binary streaming protocol, JSON-RPC protocol
Issues
  • Windows client

    Windows client

    I would really like a Windows Client too, first as I don't need another device when I work on my PC and secondly with the Raspberry Pi supporting Windows 10 IoT it might be a good alternative for a music player.

    We discussed this a bit in #22, and I just wanted to add a issue for this so it's not forgotten.

    I will try to provide information for this, maybe I even find the time to start on it myself. But I unfortunately am pretty much occupied with Greenshot so there are no guarantees.

    Here is some information which might help:

    Yesterday someone from Microsoft added example documentation for writing a Background audio app for the Universal Windows Platform (UWP): https://blogs.windows.com/buildingapps/2016/01/13/the-basics-of-background-audio/ This might be a nice way to integrate SnapCast into Windows 10, having a standard volume/play/pause control.

    There is also sample code available for an AdaptiveStreaming application: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/AdaptiveStreaming Maybe this, combined with the information on how SnapCast works, can result in an Rapsberry Pi music "box". :)

    help wanted next release 
    opened by Lakritzator 154
  • Dropouts with snapclient v0.23 and ALSA backend

    Dropouts with snapclient v0.23 and ALSA backend

    I'm running snapserver on a small Intel server and snapclient on various Raspberry PI (2,3,4). Last weekend I started to upgrade the server and clients from snapcast v.0.19. to snapcast v.0.23. On the server I'm using pulse audio with the following snapserver configuration: **source = pipe:///tmp/snapfifo?name=snapcast&mode=read The linux clients use the alsa audio interface and don't have pulse installed. I can't remember any problem with snapclient v.0.19, but with snapclient v.0.23 I was faced with terrible dropouts (see logs). Downgrading the client to v.0.19 fixed the issue. Unfortunately I'm not deep enough in technical details to provide more information. Here is my OS configuration:

    Server: Linux cms 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux --- snapserver & snapclient v.0.23 => no issues Client: Linux amadeus 5.4.83-v7+ #1379 SMP Mon Dec 14 13:08:57 GMT 2020 armv7l GNU/Linux --- snapclient v.0.23 (alsa, no pulse installed) => dropouts, downgrade to snapclient v.0.19 fixed the problem

    snapclient v0.23.0: DROPOUTS

    Jan 18 15:23:32 amadeus systemd[1]: Started Snapcast client.
    Jan 18 15:23:32 amadeus snapclient[929]: Resolving host IP for: cms
    Jan 18 15:23:32 amadeus snapclient[929]: Connecting
    Jan 18 15:23:32 amadeus snapclient[929]: Connected to 192.168.1.37
    Jan 18 15:23:32 amadeus snapclient[929]: My MAC: "b8:27:eb:4c:0b:d0", socket: 9
    Jan 18 15:23:33 amadeus snapclient[929]: ServerSettings - buffer: 1000, latency: 0, volume: 0, muted: 1
    Jan 18 15:23:33 amadeus snapclient[929]: metadata:{"STREAM":"snapcast"}
    Jan 18 15:23:33 amadeus snapclient[929]: Codec: flac, sampleformat: 48000:16:2
    Jan 18 15:23:33 amadeus snapclient[929]: Player name: alsa, device: default, description: <none>, idx: 3, sharing mode: unspecified, parameters: <non
    Jan 18 15:23:33 amadeus snapclient[929]: Mixer mode: software, parameters: <none>
    Jan 18 15:23:33 amadeus snapclient[929]: Sampleformat: 48000:16:2, stream: 48000:16:2
    Jan 18 15:23:33 amadeus snapclient[929]: Using buffer_time: 80 ms, fragments: 4
    Jan 18 15:23:33 amadeus snapclient[929]: PCM name: default, sample rate: 48000 Hz, channels: 2, buffer time: 250020 us, periods: 2, period time: 1250
    Jan 18 15:23:33 amadeus snapclient[929]: No chunks available
    Jan 18 15:23:33 amadeus snapclient[929]: Failed to get chunk
    Jan 18 15:23:33 amadeus snapclient[929]: diff to server [ms]: 5.73622e+07
    Jan 18 15:23:38 amadeus snapclient[929]: No chunk received for 5000ms. Closing ALSA.
    Jan 18 15:24:12 amadeus snapclient[929]: ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
    Jan 18 15:24:12 amadeus snapclient[929]: PCM name: default, sample rate: 48000 Hz, channels: 2, buffer time: 250020 us, periods: 2, period time: 1250
    Jan 18 15:24:17 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5981, delay: 6020, using snd_pcm_avail amd snd_pcm_del
    Jan 18 15:24:17 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6020
    Jan 18 15:24:18 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
    Jan 18 15:24:18 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5906, delay: 6095, using snd_pcm_avail amd snd_pcm_del
    Jan 18 15:24:18 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6095
    Jan 18 15:24:19 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -102804
    Jan 18 15:24:20 amadeus snapclient[929]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 5955, delay: 6037, using snd_pcm_avail amd snd_pcm_del
    Jan 18 15:24:20 amadeus snapclient[929]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 6037
    Jan 18 15:24:22 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -100639
    Jan 18 15:24:22 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
    Jan 18 15:24:25 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
    Jan 18 15:24:26 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -242589
    Jan 18 15:24:27 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
    Jan 18 15:24:29 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -243876
    Jan 18 15:24:30 amadeus snapclient[929]: XRUN while writing to PCM: Broken pipe
    Jan 18 15:24:32 amadeus snapclient[929]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -243456
    

    snapclient v0.19.0

    2021-01-18 15-31-21 [Info] (browse_callback) (Browser) CACHE_EXHAUSTED
    2021-01-18 15-31-21 [Info] (resolve_callback) Service 'Snapcast' of type '_snapcast._tcp' in domain 'local':
    2021-01-18 15-31-21 [Info] (resolve_callback)   cms.local:1704 (192.168.1.37)
    2021-01-18 15-31-21 [Info] (main) Found server 192.168.1.37:1704
    2021-01-18 15-31-21 [Info] (main) Latency: 0
    2021-01-18 15-31-21 [Notice] (start) Connected to 192.168.1.37
    2021-01-18 15-31-21 [Info] (getMacAddress) My MAC: "b8:27:eb:4c:0b:d0", socket: 6
    2021-01-18 15-31-21 [Info] (onMessageReceived) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
    metadata:{"STREAM":"snapcast"}
    2021-01-18 15-31-21 [Info] (onMessageReceived) Codec: flac
    2021-01-18 15-31-21 [Notice] (state) sampleformat: 48000:16:2
    2021-01-18 15-31-21 [Info] (Alsa) frames: 6000
    2021-01-18 15-31-21 [Info] (Alsa) Resizing buffer from 0 to 48004
    2021-01-18 15-31-21 [Info] (Stream) no chunks available
    2021-01-18 15-31-21 [Info] (Alsa) Failed to get chunk
    2021-01-18 15-31-22 [Info] (worker) diff to server [ms]: 5.73622e+07
    2021-01-18 15-31-22 [Info] (Stream) Chunk: -1   -1      -1      -1      1       124     0
    2021-01-18 15-31-23 [Info] (Stream) Chunk: -1   -1      -1      -1      4       124     0
    2021-01-18 15-31-24 [Info] (Stream) Chunk: 0    0       0       0       12      125     0
    2021-01-18 15-31-25 [Info] (Stream) Chunk: 0    0       0       0       20      125     0
    2021-01-18 15-31-26 [Info] (Stream) Chunk: -1   0       0       0       28      124     0
    2021-01-18 15-31-27 [Info] (Stream) Chunk: 3    0       0       0       36      125     0
    2021-01-18 15-31-28 [Info] (Stream) Chunk: 3    2       0       0       44      125     0
    2021-01-18 15-31-29 [Info] (Stream) Chunk: 4    3       0       0       52      124     0
    2021-01-18 15-31-30 [Info] (Stream) Chunk: 4    3       1       1       60      125     0
    
    bug next release 
    opened by mrdago 63
  • New input plugin: TCP stream

    New input plugin: TCP stream

    I'm currently using MPD as input for snapcast (connected via pipe) and now I started playing with Mopidy, which seems to be more actively developed and more feature rich. I've observed some strange audio loops during my Mopidy tests, using this setup GStreamer setup:

    [audio]
    output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo
    

    I was wondering if there are GStreamer sinks that are more reliable and implemented a TCP stream that can be configured to act as client or as server, allowing the following setups:

    Snapcast running in TCP server mode

    snapcast.conf:

    [stream]
    stream = tcp://127.0.0.1?name=mopidy_tcp
    

    the general pattern is: tcp://<IP of the listen interface>:<port>?name=<name>&mode=[client|server] default for port (if omitted) is 4953, default for mode is server

    mopidy.conf (running GStreamer in client mode)

    [audio]
    output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! tcpclientsink
    

    Snapcast running in TCP client mode

    snapcast.conf:

    [stream]
    stream = tcp://127.0.0.1?name=mopidy_tcp&mode=client
    

    in client mode the IP and port are the server's IP, port to connect to (default for port is again 4953)

    mopidy.conf (running GStreamer in server mode)

    [audio]
    output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! tcpserversink
    

    If you want to give it a try: it's available in the current develop branch, any feedback is appreciated! This would also solve #486 (well, at least it would work around it)

    opened by badaix 54
  • ALSA Resample Input - Use more Player with Snapcast

    ALSA Resample Input - Use more Player with Snapcast

    Hi someone get snapcast runnig with the spotify-connect-web client ? https://github.com/Fornoth/spotify-connect-web

    I try to route the alsa output to the fifo but i didn´t get it working ...

    opened by bjwelker 38
  • unstable playback

    unstable playback

    Client: Raspberry Pi Zero + raspbian buster + snapclient 0.20 Server: Ubuntu 20.04 amd64 + snapserver 0.20

    Hi,

    i am using snapcast since a long time (0.12 or so) it worked, sometimes there were short drop outs, but they were seldom and that was ok. Mostly a reboot of the client helped to get it working for many days. Since 0.20 now, i do not get a reliable playback. I have 2 clients atm (the volumio client shows a seg fault, so i disabled it for now) This log is from a raspberry pi zero with hdmi output (analog adapter to a simple speaker (Bathroom)).

    snapclient.log

    [info: i redacted the server host IP and the client mac]

    On the " (Stream) pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50)" lines the sound drops and comes back, sometimes i can play more, sometimes it happens on every some seconds. I tested it with urandom now, to rule out mpd -> pulse fifo and it happens also. The ntp time is set and correct on all clients. Its wifi,so i increased the buffer form 750ms to now 2000ms but all does not help. I tried also to change the format, this also does not help. Sometimes there is a "(Alsa) failed to get chunk message right befor the "Stream pMini ..." line.

    I know, somewhere was the info, what the Stats line and the columns means, but i dont found it :)

    @badaix Any hints on what to do to get it fixed ?

    (The other raspi is also a pi zero with a hifibery dac hat, there it happens also, but i have no log atm for it)

    Many Thanks Ronny

    opened by rcmcronny 38
  • Integrate Snapcast Server/Client in Kodi

    Integrate Snapcast Server/Client in Kodi

    If snapcast would be available in Kodi, then it would be much easier to have multiroom-audio.

    You can have a "Music-server" which is the snapcast-server also. Then you could connect all other Kodi instances (zones) to it and control it via UPnP (from Kodi -> JSON) from every client or the server.

    This would need a Win/MacOS port, btw. The next benefit would be, it could then go to LibreElec also.

    opened by walterheisenberg 35
  • Snapserver at 100% CPU after Android client connects

    Snapserver at 100% CPU after Android client connects

    running version 0.10.0 on an pi2 with a 2.041 volumio image. whenever I start the android client the snapserver goes up to 100% cpu and stays there even after closing the android app. The server logs one exception:

    Jan 30 21:13:54 volumio snapserver[18048]: Exception in ControlSession::reader(): read_until: End of file

    opened by treb42 34
  • [Question] Setting up Bluetooth A2DP audio sink

    [Question] Setting up Bluetooth A2DP audio sink

    I have a pi3 which runs snapserver and snapclient. Mopidy and librespot both run well. Now I wanted to add a2dp to the pi3. I followed this gist which is using bluealsa.

    So my understanding is that I need to configure Alsa to write another fifo file in /tmp. But when I add /etc/asound.conf as described here I dont hear anything from my pi3. Only snapclients connected play correctly. When reverting the changes to asound.conf everything except bluetooth is working again. Can someone give me an hint what I did wrong? Thanks!

    opened by herrwusel 32
  • Snapclient with multiple audio hardware

    Snapclient with multiple audio hardware

    Hi

    How do I get snapclient to work with multiple audio devices (on the same pc) that have different capabilties?

    I had an issue with snapclient that it was not able to play with the default soundcard because I am guessing it was an sampling format issue "Exception in Controller::worker(): Can't open default:CARD=PCH PCM device: Device or resource busy"

    Now I do not want to decrease the default sampling but I need to change the default format for the internal audio(that has the issue)

    So how do I make snapclient to use multiple hardwares? I would like it to output multiple devices at once on the same pc.

    The sound is sent from Mpd.

    thanks

    opened by gerroon 29
  • Audio distortion / clicks and pops - replace CLOCK_REALTIME with CLOCK_MONOTONIC

    Audio distortion / clicks and pops - replace CLOCK_REALTIME with CLOCK_MONOTONIC

    snapcast uses the system clock of the server as a source for playback. This clock is not continous. Playing audio synchronized to a jumping clock likely causes pops.

    On the client-side a monotonic clock should be used to determine when a chunk is to be played. An offset to the server should be maintained and adjusted periodically.

    EDIT: I have found this not to be correct. We can play back synchronized when relying on NTP and CLOCK_REALTIME just fine.

    opened by christf 29
  • Provide Official Docker Images?

    Provide Official Docker Images?

    Is your feature request related to a problem? Please describe.

    I'd like to run snapserver on my home server which uses Fedora IoT. Fedora IoT is built for running OCI containers, i.e. Docker containers, and having an official Docker container would make this much easier to use in this configuration. This would also make deployment and management much easier. I'd also like to eventually run the snapclient within a Docker container as well.

    Describe the solution you'd like

    I'd like to see official Docker images provided by the project on a popular container registry like Dockerhub, Quay.io, etc. for running snapserver and snapclient. I currently run my Fedora IoT server on an aarch64 machine, so it would be great if the provided image was available for that architecture.

    Describe alternatives you've considered

    I can build my own Dockerfile and build the Docker image myself, but this seems like it would needlessly duplicate work if others would like to use snapserver from within a Docker container.

    Additional context

    I haven't seen anyone else mention a Docker image here, unless I missed a previous request. Anyways, I understand this is a lot of work, but figured it was at least worth asking.

    feature request 
    opened by jwillikers 0
  • Small documentation corrections

    Small documentation corrections

    This PR fixes small typos in the documentation and adds missing build dependencies necessary for building on Fedora. This PR also adds the host option to the Mopidy configuration examples when using the TCP source. Without host=127.0.0.1 I wasn't able to get the examples to work.

    Some small improvements were made to the ALSA backend configuration examples. The ALSA loopback device is now referred to by name instead of index since the index is subject to change.


    Pull Request Checklist

    • Contributions must be licensed under the GPL-3.0 License

    • This project loosely follows the Google C++ Style Guide

    • For better compatibility with embedded toolchains, the used C++ standard should be limited to C++14

    • 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.

    • 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.
    opened by jwillikers 2
  • Improve perceived responsiveness to pause/skip

    Improve perceived responsiveness to pause/skip

    Snapcast responds quickly to sound starting to play but, due to buffering, seems sluggish when responding to a pause/skip.

    Could snapserver accept a control signal to flush the existing buffer and tell clients to do so as well.

    Stream playback would resume immediately with an empty buffer (just as it does when a stream begins)

    This would need additional support from clients however in the interim a helper client listening to the mpd control protocol could easily respond to such events and signal snapserver to tell the clients to perform a buffer flush.

    feature request 
    opened by lbt 0
  • Stuttering in sound

    Stuttering in sound

    I am trying to make a smart speaker just like a Sonos, with SnapCast as the music system and Rhasspy as the smart assistant system. I have a dedicated server for the SnapServer (v0.25.0 (rev 2af5292f)) and also a dedicated server for Rhasspy to handle all the smart assistant features that can be offloaded to this system. The smart speaker is just running 2 things, SnapClient (Version 0.25.0, revision 2af5292f) and Rhasspy with wakeword/Audio commands and Text to Speak features.

    The dedicated SnapCast server, called Jukebox, is an Intel Core i7-6820HQ CPU with 24Gb ram and a SSD for storage, where the media files are also located. This is running on a 64bit Debian Bullseye Linux with Mopidy as a feeder to the SnapServer. Snapserver is installed from the .deb package.

    The smart speaker, called RhasspySat, is a Raspberry Pi 4B, 4Gb with a Seeed Respeaker 4-Mic Linear Array Kit Audio Hat (https://wiki.seeedstudio.com/ReSpeaker_4-Mic_Linear_Array_Kit_for_Raspberry_Pi/) used both for recording and playing. This on is running the 32bit Raspberry OS based on Buster. Snapclient is installed from the .deb package.

    SnapClient seems to playing fine on the Rhasspy if I use a direct hardware device, like ac108. It still have a few lines in the syslog now and then, but it does not affect the sound at all. The problem is I need to use the dmixer instead to allow Rhasspy access to the speaker too and that output device causes a lot of stuttering in the sound. Shutting down the Rhasspy Client does not affect the stuttering.

    What I noticed is that the Snapclient is increasing the period and buffer size from the default, which does not occur when I use the ac108 directly. I have provided what info I thought might be useful in solving this. If anything else is needed then please ask and I hope you can then help me solve it.

    Jukebox Snapserver.conf:

    [server]
    threads = -1
    pidfile = /var/run/snapserver/pid
    
    [http]
    enabled = true
    bind_to_address = 0.0.0.0
    port = 1780
    
    [tcp]
    enabled = true
    bind_to_address = 0.0.0.0
    port = 1705
    
    [stream]
    bind_to_address = 0.0.0.0
    port = 1704
    source = pipe:///tmp/snapfifo?name=default
    sampleformat = 48000:16:2
    codec = pcm
    chunk_ms = 20
    buffer = 2000
    send_to_muted = false
    
    [logging]
    sink = system
    filter = *:info
    

    Rhasspy /etc/asound.conf:

    defaults.pcm.rate_converter "samplerate_best"
    
    pcm.!default {
        type asym
        playback.pcm "dmixer"
        capture.pcm "ac108"
    }
    
    pcm.ac108 {
        type plug
        slave {
            rate 48000
            format S32_LE
            pcm "hw:seeed8micvoicec"
        }
    }
    
    pcm.dmixer {
        type plug
        slave {
            pcm {
                type dmix
                ipc_key 555555
                ipc_perm 0666
                slave {
                    pcm "hw:seeed8micvoicec"
                    format S32_LE
                    channels 8
                }
                bindings {
                    0 0
                    1 1
                    2 2
                    3 3
                    4 4
                    5 5
                    6 6
                    7 7
                }
            }
            channels 8
            format S32_LE
            rate 48000
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.0.2 1
        ttable.1.3 1
        ttable.0.4 1
        ttable.1.5 1
        ttable.0.6 1
        ttable.1.7 1
    }
    
    pcm.ac101 {
        type plug
        slave {
            pcm "hw:seeed8micvoicec"
            channels 8
            format S32_LE
            rate 16000
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.0.2 1
        ttable.1.3 1
        ttable.0.4 1
        ttable.1.5 1
        ttable.0.6 1
        ttable.1.7 1
    }
    

    RhasspySat Snapclient OPTS: "-h 10.10.12.70 -p 1704 -s 5 --player alsa --logsink system -e --logfilter *:debug"

    RhasspySat> device list

    0: null
    Discard all samples (playback) or generate zero samples (capture)
    
    1: jack
    JACK Audio Connection Kit
    
    2: pulse
    PulseAudio Sound Server
    
    3: default
    
    4: ac108
    
    5: dmixer
    
    6: ac101
    
    7: sysdefault:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
    
    8: dmix:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
    
    9: dsnoop:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample snooping device
    
    10: hw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
    
    11: plughw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions
    
    12: usbstream:CARD=Headphones
    bcm2835 Headphones
    USB Stream Output
    
    13: sysdefault:CARD=seeed8micvoicec
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Default Audio Device
    
    14: dmix:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct sample mixing device
    
    15: dsnoop:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct sample snooping device
    
    16: hw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct hardware device without any conversions
    
    17: plughw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Hardware device with all software conversions
    
    18: usbstream:CARD=seeed8micvoicec
    seeed-8mic-voicecard
    USB Stream Output
    

    RhasspySat> Syslog:

    Nov  8 09:13:23 rhasspysat1 systemd[1]: Started Snapcast client.
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Trying to get PCM device for player: alsa, parameter: , card: 5
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Version 0.25.0, revision 2af5292f
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Resolving host IP for: 10.10.12.70
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Connecting
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Connected to 10.10.12.70
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: My MAC: "dc:a6:32:3f:c4:5e", socket: 9
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: outstanding async_write
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: ServerSettings - buffer: 2000, latency: 0, volume: 100, muted: 0
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: metadata:{"STREAM":"default"}
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Codec: pcm, sampleformat: 48000:16:2
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Player name: alsa, device: dmixer, description: <none>, idx: 5, sharing mode: unspecified, parameters: <none>
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Mixer mode: software, parameters: <none>
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Sampleformat: 48000:16:2, stream: 48000:16:2
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Using default buffer_time: 80 ms, default fragments: 4
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: ACCESS:  MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: FORMAT:  S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: SUBFORMAT:  STD
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: SAMPLE_BITS: [4 64]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: FRAME_BITS: [4 640000]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: CHANNELS: [1 10000]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: RATE: [4000 4294967295)
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: PERIOD_TIME: 125000
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: PERIOD_SIZE: [500 536870912)
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: PERIOD_BYTES: [250 4294967295)
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: PERIODS: (0 2147484)
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: BUFFER_TIME: [1 4294967295]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: BUFFER_SIZE: [1000 1073741823]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: BUFFER_BYTES: [500 4294967295]
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: TICK_TIME: ALL
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Period time too small, changing from 20000 to 125000
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Buffer time smaller than 3 * periods: 80000 us < 375000 us, raising buffer time
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: PCM name: dmixer, sample rate: 48000 Hz, channels: 2, buffer time: 250000 us, periods: 2, period time: 125000 us, period frames: 6000
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: setVolume exp with base 10: 1 => 1
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Resizing buffer from 0 to 48000
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: No chunks available
    Nov  8 09:13:23 rhasspysat1 snapclient[1802]: Failed to get chunk
    Nov  8 09:13:24 rhasspysat1 snapclient[1802]: diff to server [ms]: 2.97706e+08
    Nov  8 09:13:24 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 12000, delay: 0, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:24 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 0
    Nov  8 09:13:24 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11946, delay: 53, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:24 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 53
    Nov  8 09:13:25 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11944, delay: 56, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:25 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 56
    Nov  8 09:13:25 rhasspysat1 snapclient[1802]: Silent frames: 6707, frames: 12000, age: -139.741
    Nov  8 09:13:25 rhasspysat1 snapclient[1802]: Chunk: 32#01132#01132#01132#0111#01114#0110
    Nov  8 09:13:26 rhasspysat1 snapclient[1802]: Chunk: 32#01132#01132#01132#0112#0110#0110
    Nov  8 09:13:26 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11988, delay: 11, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:26 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 11
    Nov  8 09:13:27 rhasspysat1 snapclient[1802]: Chunk: 161#01132#01132#01132#0116#0116#0110
    Nov  8 09:13:27 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11861, delay: 139, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:27 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 139
    Nov  8 09:13:28 rhasspysat1 snapclient[1802]: Chunk: 308#011161#011161#011161#01110#01110#0110
    Nov  8 09:13:28 rhasspysat1 snapclient[1802]: XRUN while writing to PCM: Broken pipe
    Nov  8 09:13:29 rhasspysat1 snapclient[1802]: Chunk: -2144#011146#011146#011146#01115#0110#0110
    Nov  8 09:13:29 rhasspysat1 snapclient[1802]: XRUN while writing to PCM: Broken pipe
    Nov  8 09:13:30 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11975, delay: 24, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:30 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 24
    Nov  8 09:13:30 rhasspysat1 snapclient[1802]: Chunk: -4463#01132#01132#01132#01120#0110#0110
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -214393
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: Chunk: -4430#011-2144#01132#01132#01124#0111#0110
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: Silent frames: 9272, frames: 11997, age: -193.178
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: XRUN while writing to PCM: Broken pipe
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 12000, delay: 0, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:31 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 0
    Nov  8 09:13:32 rhasspysat1 snapclient[1802]: Chunk: -2325#011-2342#011-2342#011-2342#0113#01116#0110
    Nov  8 09:13:32 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11942, delay: 57, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:32 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 57
    Nov  8 09:13:33 rhasspysat1 snapclient[1802]: Chunk: -2131#011-2325#011-2325#011-2325#0117#0111#0110
    Nov  8 09:13:33 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11938, delay: 61, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:33 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 61
    Nov  8 09:13:34 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11915, delay: 85, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:34 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 85
    Nov  8 09:13:34 rhasspysat1 snapclient[1802]: Chunk: -1813#011-2131#011-2131#011-2131#01111#0110#0110
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: Chunk: -1776#011-2017#011-2017#011-2017#01115#0110#0110
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: XRUN while writing to PCM: Broken pipe
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 12000, delay: 0, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 0
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11191, delay: 808, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:35 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 808
    Nov  8 09:13:36 rhasspysat1 snapclient[1802]: Chunk: -3941#011-2131#011-2131#011-2131#01120#01114#0110
    Nov  8 09:13:36 rhasspysat1 snapclient[1802]: pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): -213121
    Nov  8 09:13:36 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11944, delay: 56, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:36 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 56
    Nov  8 09:13:36 rhasspysat1 snapclient[1802]: Silent frames: 6193, frames: 11335, age: -129.026
    Nov  8 09:13:37 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11335, delay: 664, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:37 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 664
    Nov  8 09:13:37 rhasspysat1 snapclient[1802]: Chunk: 122#011122#011122#011122#0111#0110#0110
    Nov  8 09:13:37 rhasspysat1 snapclient[1802]: snd_pcm_avail_delay failed: Broken pipe (-32), avail: 11226, delay: 774, using snd_pcm_avail amd snd_pcm_delay.
    Nov  8 09:13:37 rhasspysat1 snapclient[1802]: snd_pcm_delay failed: Broken pipe (-32), avail: -32, delay: 774
    Nov  8 09:13:38 rhasspysat1 snapclient[1802]: Chunk: 356#011315#011315#011315#0115#0111#0110
    Nov  8 09:13:38 rhasspysat1 snapclient[1802]: XRUN while writing to PCM: Broken pipe
    
    opened by WallyDW 1
  • WebAudio: Send data from client as TCP

    WebAudio: Send data from client as TCP

    Similar to the broadcast-functionality of the Snap.Net-app, one could use WebAudio to broadcast from client to server:

    https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

    JS-Example of using WebAudio including input device selection and asking for user-permission in browser: https://github.com/YeonV/wled-manager/blob/v0.0.9/renderer/components/AudioContainer.jsx#L41-L65

    feature request 
    opened by YeonV 0
  • Disconnect from pulse temporarily while there are no chunks available

    Disconnect from pulse temporarily while there are no chunks available

    Disconnect from pulseaudio when no chunk has been received for 5000 ms. (same as the alsa player).

    When new chunks arrive, reconnect to pulseaudio and resume playing.

    This enables the pulseaudio sink to go into an idle/suspended state for powersaving, and saves cpu cycles on the snapclient when no sound is being played.

    Closes: https://github.com/badaix/snapcast/issues/927

    opened by nkvoll 6
  • Make it possible to override sampleformat for librespot streams

    Make it possible to override sampleformat for librespot streams

    Allow the user to set a sampleformat for librespot streams, but provide the old stream-specific default of 44100:16:2.

    Adds a small snippet to the configuration documentation explaining how to set the sample rate to 24 bit for librespot.

    Closes https://github.com/badaix/snapcast/issues/929

    opened by nkvoll 5
  • Enable configuring the sample format for librespot streams

    Enable configuring the sample format for librespot streams

    librespot supports (among others) 24 bit sample format (through command line options).

    Currently snapserver has the sampleformat of 44100:16:2 hardcoded for librespot streams. This seems like a reasonable default because if a user changes the default sampleformat = in the configuration file, it's all too easy to break the setup.

    However, since librespot exposes it, it would be great if there existed a way to take advantage of the higher sample format.

    feature request 
    opened by nkvoll 0
  • Add librespot-java stream source

    Add librespot-java stream source

    librespot-java provides an API for local control of the spotify client whereas librespot does not.

    I'd like to see librespot-java considered as an (autodetected?) alternative for librespot:// or as an additional librespot-java:// stream source.

    Counter-argument that librespot-java isn't as active as librespot.

    Another counter-argument: just use process://. (What advantage is there internally for snapcast having specific stream sources instead of just process://? Is it the metadata formats?)

    For reference spocon packages librespot-java for Debian, etc.

    Thoughts?

    feature request 
    opened by markferry 1
  • With pulse/pulseaudio, snapclient keeps logging no chunks available and keeps soundcard from suspending.

    With pulse/pulseaudio, snapclient keeps logging no chunks available and keeps soundcard from suspending.

    When using snapclient --player pulse, the client logs [Info] (Stream) No chunks available every second. While the logging does not bother me, it seems it also does not release the sound cards, so they're kept in RUNNING state perpetually:

    $ pactl list sinks short
    0       alsa_output.pci-0000_05_00.0.analog-stereo      module-alsa-card.c      s16le 2ch 48000Hz       RUNNING
    1       alsa_output.usb-Creative_Technology_Ltd_Sound_Blaster_Play__3_00237830-00.analog-stereo module-alsa-card.c      s16le 2ch 48000Hz       RUNNING
    2       alsa_output.usb-Solid_State_System_Co._Ltd._USB_Gaming_Box_1234567896F3-00.analog-stereo        module-alsa-card.c      s24le 2ch 48000Hz       RUNNING
    

    In a setup where I'm running 4 snapclients I'm also noting that this seems to cause pulseaudio to take roughly 10% CPU (recent AMD Ryzen 5), and each snapclient instance taking around 1%. In my setup, pulseaudio is also doing some remixing, but if I stop the snapclients, its CPU drops to 0%, so it looks like it's processing silence? If this is the case, would it be possible to stop playing / sending sound when the stream they're following is idle?

    Steps to Reproduce

    1. Start a snapserver with any config
    2. Start a snapclient like in the below example
    3. Check pactl list sinks short.

    Environment

    • OS: debian
    • Snapcast version 0.25.0 (tested with the latest release and last build from the develop branch.)

    Logfile

    $ snapclient -h 192.168.2.234 --player pulse --mixer hardware --logfilter debug
    2021-10-17 22-36-32.885 [Debug] (Snapclient) Trying to get PCM device for player: pulse, parameter: , card: default
    2021-10-17 22-36-32.898 [Info] (Snapclient) Version 0.25.0, revision 4f2f16db
    2021-10-17 22-36-32.898 [Info] (Connection) Resolving host IP for: 192.168.2.234
    2021-10-17 22-36-32.898 [Info] (Connection) Connecting
    2021-10-17 22-36-32.898 [Notice] (Connection) Connected to 192.168.2.234
    2021-10-17 22-36-32.898 [Info] (Connection) My MAC: "52:54:00:53:68:47", socket: 8
    2021-10-17 22-36-32.921 [Debug] (Connection) outstanding async_write
    2021-10-17 22-36-32.922 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 100, muted: 0
    2021-10-17 22-36-32.922 [Warn] (Connection) Failed to deserialize message of type: StreamTags
    2021-10-17 22-36-32.923 [Info] (Controller) Codec: flac, sampleformat: 48000:16:2
    2021-10-17 22-36-32.923 [Info] (Player) Player name: pulse, device: default, description: Let PulseAudio server choose the device, idx: 7, sharing mode: unspecified, parameters: <none>
    2021-10-17 22-36-32.923 [Info] (Player) Mixer mode: hardware, parameters: <none>
    2021-10-17 22-36-32.923 [Info] (Player) Sampleformat: 48000:16:2, stream: 48000:16:2
    2021-10-17 22-36-32.923 [Info] (PulsePlayer) Setting property "application.icon_name" to "snapcast"
    2021-10-17 22-36-32.923 [Info] (PulsePlayer) Setting property "media.role" to "music"
    2021-10-17 22-36-32.923 [Info] (PulsePlayer) Using buffer_time: 100 ms, server: default
    2021-10-17 22-36-32.923 [Debug] (PulsePlayer) State changed 2: authorizing
    2021-10-17 22-36-32.929 [Debug] (PulsePlayer) State changed 3: setting name
    2021-10-17 22-36-32.932 [Debug] (PulsePlayer) State changed 4: ready
    2021-10-17 22-36-32.934 [Info] (Stream) outputBufferDacTime > bufferMs: 139692691104 > 1000
    2021-10-17 22-36-32.934 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-32.935 [Debug] (PulsePlayer) event_type: 0, facility: 2
    2021-10-17 22-36-32.935 [Info] (Stream) No chunks available
    2021-10-17 22-36-32.936 [Debug] (PulsePlayer) pa_context_get_sink_info_by_index info: 1, eol: 0
    2021-10-17 22-36-32.936 [Debug] (PulsePlayer) Volume changed: 1, muted: 0
    2021-10-17 22-36-32.936 [Debug] (PulsePlayer) Last volume change by server: 2 ms => ignoring volume change
    2021-10-17 22-36-32.936 [Debug] (PulsePlayer) pa_context_get_sink_info_by_index info: 0, eol: 1
    2021-10-17 22-36-32.962 [Info] (Controller) diff to server [ms]: 0.006
    2021-10-17 22-36-33.019 [Info] (Stream) No chunks available
    2021-10-17 22-36-33.939 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-34.029 [Info] (Stream) No chunks available
    2021-10-17 22-36-34.959 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-35.009 [Info] (Stream) No chunks available
    2021-10-17 22-36-35.979 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-36.019 [Info] (Stream) No chunks available
    2021-10-17 22-36-36.988 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-37.009 [Info] (Stream) No chunks available
    2021-10-17 22-36-37.999 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-38.029 [Info] (Stream) No chunks available
    2021-10-17 22-36-39.009 [Info] (Stream) No chunks available
    2021-10-17 22-36-39.009 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-40.019 [Info] (Stream) No chunks available
    2021-10-17 22-36-40.019 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-41.010 [Info] (Stream) No chunks available
    2021-10-17 22-36-41.029 [Debug] (Stream) Failed to get chunk, returning silence
    2021-10-17 22-36-42.019 [Info] (Stream) No chunks available
    2021-10-17 22-36-42.039 [Debug] (Stream) Failed to get chunk, returning silence
    
    
    opened by nkvoll 0
Releases(v0.25.0)
Owner
Johannes Pohl
Strange things are afoot at the Circle K...
Johannes Pohl
a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++

musikcube a cross-platform, terminal-based audio engine, library, player and server written in c++. musikcube compiles and runs easily on windows, mac

casey langen 2.6k Nov 30, 2021
Rygel is a home media solution that allows you to easily share audio, video and pictures, and control of media player on your home network

Rygel is a home media solution that allows you to easily share audio, video and pictures, and control of media player on your home network. In technical terms it is both a UPnP AV MediaServer and MediaRenderer implemented through a plug-in mechanism. Interoperability with other devices in the market is achieved by conformance to very strict requirements of DLNA and on the fly conversion of media to format that client devices are capable of handling.

GNOME Github Mirror 51 Nov 30, 2021
Audio and video casting system with support for custom applications.

Repository Structure · Getting Started · Building From Source · Developer's Guide · SDK · License · Donate What is NymphCast? NymphCast is a software

Maya Posch 2k Nov 29, 2021
A web based audio/video streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device.

Ampache www.ampache.org | ampache.github.io News: Keep an eye on the incoming changes to develop branch at Ampache-Next-Changes The Ampache kodi plugi

null 2.9k Nov 28, 2021
Simple personal server to serve audiofiles files from folders. Intended primarily for audio books, but anything with decent folder structure will do.

Audioserve !!PLEASE UPDATE TO v0.15.0 (or newer) DUE TO IMPORTANT SECURITY FIX!! [DEMO AVAILABLE - shared secret: mypass] Simple personal server to se

Ivan Zderadicka 291 Nov 30, 2021
Remote music player that supports adding more content

Compactd . (pronounce compact-D) Compactd aims to be a self-hosted remote music player in your browser, streaming from you own personal server. It wil

null 80 Sep 26, 2021
Music player server with a web-based user interface.

Music player server with a web-based user interface. Run it on a server connected to some speakers in your home or office. Guests can control the musi

Andrew Kelley 1.8k Nov 20, 2021
Music Player Daemon

Music Player Daemon http://www.musicpd.org A daemon for playing music of various formats. Music is played through the server's audio device. The daemo

Music Player Daemon 1.5k Nov 20, 2021
Beautiful web-based music player

Stretto An open source web-based music player Go to Stretto, or if you would like to host it yourself, scroll down to the developer instructions. How

Benjamin Kaiser 555 Nov 17, 2021
Volumio 2 - Audiophile Music Player

Volumio is an headless audiophile music player, designed to play music with the highest possible fidelity. Volumio runs on most embedded devices (Rasp

Volumio 1.3k Nov 26, 2021
VLC is a popular libre and open source media player and multimedia engine,

VLC is a popular libre and open source media player and multimedia engine, used by a large number of individuals, professionals, companies and institutions. Using open source technologies and libraries, VLC has been ported to most computing platforms, including GNU/Linux, Windows, Mac OS X, BSD, iOS and Android.

VideoLAN 8.2k Nov 26, 2021
Web-based music player for the cloud :cloud: :notes: Play music from YouTube, Dropbox, etc.

CloudTunes Open source, web-based music player for the cloud. Also on: Facebook • Twitter • Hacker News • Lifehacker CloudTunes provides a unified int

Jakub Roztocil 2.5k Nov 23, 2021
Python library which provides a client interface for the Music Player Daemon.

python-mpd2 python-mpd2 is a Python library which provides a client interface for the Music Player Daemon. Difference with python-mpd python-mpd2 is a

Jörg Thalheim 312 Nov 26, 2021
OBPlayer is a stable and secure UNIX-based media streaming playout application that can operate as a standalone player or controlled over a network by a managing OBServer instance.

OBPlayer is a stable and secure UNIX-based media streaming playout application that can operate as a standalone player or controlled over a network by a managing OBServer instance. It can be installed remotely at a transmitter site, in the studio or as a virtual headless process on a server.

OpenBroadcaster 66 Nov 11, 2021
Moode Audio Player is a derivative of the wonderful WebUI audio player client for MPD

moOde audio player Moode Audio Player is a derivative of the wonderful WebUI audio player client for MPD originally designed and coded by Andrea Coiut

Moode Audio Player 493 Nov 19, 2021
a cross-platform, terminal-based music player, audio engine, metadata indexer, and server in c++

musikcube a cross-platform, terminal-based audio engine, library, player and server written in c++. musikcube compiles and runs easily on windows, mac

casey langen 2.6k Nov 30, 2021
Rygel is a home media solution that allows you to easily share audio, video and pictures, and control of media player on your home network

Rygel is a home media solution that allows you to easily share audio, video and pictures, and control of media player on your home network. In technical terms it is both a UPnP AV MediaServer and MediaRenderer implemented through a plug-in mechanism. Interoperability with other devices in the market is achieved by conformance to very strict requirements of DLNA and on the fly conversion of media to format that client devices are capable of handling.

GNOME Github Mirror 51 Nov 30, 2021
GNOME audio player for transcription

Parlatype For a screenshot, an overview what Parlatype actually is and packages please visit https://www.parlatype.org. The following instructions are

Gabor Karsay 131 Nov 29, 2021
WebRTC audio/video call and conferencing server.

Spreed WebRTC Spreed WebRTC implements a WebRTC audio/video call and conferencing server and web client. The latest source of Spreed WebRTC can be fou

struktur AG 1k Nov 30, 2021
A chat server with OAuth2 authentication, persistent and searchable history, video and audio, markdown formatting, private and public rooms, stars, votes, embedded games, and many other features

A chat server with authentication, persistent and searchable history, rich markdown formatting, video, private rooms, conversation highlighting, plugi

Canop 501 Nov 19, 2021
Audio and video casting system with support for custom applications.

Repository Structure · Getting Started · Building From Source · Developer's Guide · SDK · License · Donate What is NymphCast? NymphCast is a software

Maya Posch 2k Nov 29, 2021
A web based audio/video streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device.

Ampache www.ampache.org | ampache.github.io News: Keep an eye on the incoming changes to develop branch at Ampache-Next-Changes The Ampache kodi plugi

null 2.9k Nov 28, 2021
Simple personal server to serve audiofiles files from folders. Intended primarily for audio books, but anything with decent folder structure will do.

Audioserve !!PLEASE UPDATE TO v0.15.0 (or newer) DUE TO IMPORTANT SECURITY FIX!! [DEMO AVAILABLE - shared secret: mypass] Simple personal server to se

Ivan Zderadicka 291 Nov 30, 2021
A free & open tool for transcribing audio interviews

oTranscribe oTranscribe is a free web app designed to take the pain out of transcribing recorded interviews. Pause (ESC), rewind (F1) and fast-forward

null 622 Nov 25, 2021
Audio Editor

Audacity is an easy-to-use, multi-track audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems. Developed by a group o

Audacity 6.7k Dec 2, 2021
The fre:ac audio converter project

fre:ac - free audio converter fre:ac is a free and open source audio converter. It supports audio CD ripping and tag editing and converts between vari

Robert Kausch 653 Nov 29, 2021