jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

Avoiding latency when playing presets across zones? #847

Open ibogost opened 1 year ago

ibogost commented 1 year ago

After some testing, it seems that the more zones I add to a preset, the more latency I encounter before the action gets performed. A single zone (even actuated as a preset) is almost instantaneous. This is mostly an issue when using clippreset for non-music purposes, such as for doorbell sounds.

I'm just trying to understand what if any software/hardware limitation is at work here. Is there any?

If so, are there workarounds possible natively inside node-sonos-http-api, such as having a container action asynchronously call other actions? Obviously, I can make my own shell script to do this, but I'd love to be able to handle everything within the API call itself.

jishi commented 1 year ago

IIRC, I saw problems with calling multiple players in parallel (mostly, the joining part, I assume), so I settled for doing everything sequential. This was a long time ago though, so not sure of the current state.

But there is also a lot of preparation for the coordinator (the player that becomes in charge of the playback) which needs to happen sequentially, since the calls depend on each other.

ibogost commented 1 year ago

Interesting. I assumed it was joining them, and that was the cause of the delay.

Here's what I notice: If I curl a request to a preset with even two rooms (zones), there's a noticeable delay, probably half a second or more. If I background (curl &) requests to two (or really, any number of) different preset plays, both play instantly. Again, I can write a shell script to do this, but it sure would be nice if the API itself would handle it.