snapcast
snapcast copied to clipboard
Snapcast emits stream notifications for streams with `codec=null`
Describe the bug
Snapcast is emitting Stream.OnUpdate
notifications for streams that are set as codec=null
. These streams are not part of the Server.GetStatus
response, and not visible in the web interface.
This causes a problem in python-snapcast because it attempts to lookup the codec=null
stream via it's name, throwing a KeyError.
Steps to Reproduce
- Define a input-only stream with
codec=null
, define a meta stream with the input-only stream as a source. - Listen for notifications from the server. e.g.
telnet localhost 1705
- Start playback on the input-only stream
- Observe 2
Stream.OnUpdate
notifications. 1 from the meta stream, 1 from the input-only stream.
Environment details
- OS: Docker w/ Alpine
- Snapserver 0.27.0
- Built via Dockerfile
Server.GetStatus response trimmed for brevity
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"server": {
"streams": [
{
"id": "Bedroom",
"status": "playing",
"uri": {
"fragment": "",
"host": "",
"path": "/upnp-bedroom/airplay-bedroom/spotify-bedroom/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms",
"query": {
"chunk_ms": "40",
"codec": "flac",
"name": "Bedroom",
"sampleformat": "44100:16:2"
},
"raw": "meta:////upnp-bedroom/airplay-bedroom/spotify-bedroom/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms?chunk_ms=40&codec=flac&name=Bedroom&sampleformat=44100:16:2",
"scheme": "meta"
}
},
{
"id": "Living Room",
"status": "idle",
"uri": {
"fragment": "",
"host": "",
"path": "/upnp-living-room/airplay-living-room/spotify-living-room/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms",
"query": {
"chunk_ms": "40",
"codec": "flac",
"name": "Living Room",
"sampleformat": "44100:16:2"
},
"raw": "meta:////upnp-living-room/airplay-living-room/spotify-living-room/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms?chunk_ms=40&codec=flac&name=Living Room&sampleformat=44100:16:2",
"scheme": "meta"
}
}
]
}
}
}
Stream.OnUpdate notification trimmed for brevity
{
"jsonrpc": "2.0",
"method": "Stream.OnUpdate",
"params": {
"id": "upnp-bedroom",
"stream": {
"id": "upnp-bedroom",
"status": "playing",
"uri": {
"fragment": "",
"host": "",
"path": "/streams/gmrender-resurrect-bedroom",
"query": {
"chunk_ms": "40",
"codec": "null",
"name": "upnp-bedroom",
"sampleformat": "44100:16:2"
},
"raw": "pipe:////streams/gmrender-resurrect-bedroom?chunk_ms=40&codec=null&name=upnp-bedroom&sampleformat=44100:16:2",
"scheme": "pipe"
}
}
}
}
{
"jsonrpc": "2.0",
"method": "Stream.OnUpdate",
"params": {
"id": "Bedroom",
"stream": {
"id": "Bedroom",
"status": "playing",
"uri": {
"fragment": "",
"host": "",
"path": "/upnp-bedroom/airplay-bedroom/spotify-bedroom/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms",
"query": {
"chunk_ms": "40",
"codec": "flac",
"name": "Bedroom",
"sampleformat": "44100:16:2"
},
"raw": "meta:////upnp-bedroom/airplay-bedroom/spotify-bedroom/upnp-all-rooms/airplay-all-rooms/spotify-all-rooms?chunk_ms=40&codec=flac&name=Bedroom&sampleformat=44100:16:2",
"scheme": "meta"
}
}
}
}
Feels a little hacky but we could add a check for the codec here:
https://github.com/badaix/snapcast/blob/6a428328aa3a7f2ece91895466b2690a5e454b17/server/server.cpp#L69-L79
e.g.
if (pcmStream->getCodec() == "null")
return;
Should be fixed with 6451ab5b8d74b33fb5c09a2840ab00151b7ecf46 You can find packages here: https://github.com/badaix/snapcast/actions/runs/8436966658
Ran some quick tests and it looked good
Fixed in version 0.28.0