Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio stutters after several minutes of streaming #133

Open
CHNtentes opened this issue May 12, 2024 · 8 comments
Open

audio stutters after several minutes of streaming #133

CHNtentes opened this issue May 12, 2024 · 8 comments
Labels
question Further information is requested

Comments

@CHNtentes
Copy link

Hi,
First of all, I want to thank you for your great work. I only expected it would be suitable for music, but it turns out that the latency is enough for video/gaming.
However, there is an issue: Every time I start streaming the audio is fine, but after some time (I would say about 10-20 minutes) , the audio begins to stutter and crack a lot. Then if I restart streaming it would work well again.
Is there any tip you could show me about this issue? I stream to a Sonos Era 100 btw.

@dheijl
Copy link
Owner

dheijl commented May 12, 2024

Is your Sonos wired or is it a WiFi connection?
Also, if you're gaming I can imagine that swyh-rs does not get enough CPU to keep up with the audio capturing. You can always try to give it a higher priority in the task manager.

@CHNtentes
Copy link
Author

Thanks for your reply.
There's no wired connection, I just connect my Sonos and PC to same Wi-Fi.
I tried to set swyh program to realtime priority in task manager, but the issue remains.
Even when I'm gaming, the CPU usage usually is less than 30%.
Could my network connection quality have something to do with this?

@dheijl
Copy link
Owner

dheijl commented May 13, 2024

This leaves 2 possibilities that I can see:

  • your wireless network is sometimes too busy, but why only after 20 minutes or so beats me

  • the sample clock of your Sonos runs slightly faster than the sample clocck of your PC, so that inevitably after a certain time the Sonos network delay buffer will get empty because the samples arrive slower than they are consumed, and restarting the music fixes it temporarily.

Edit: from 1.10.5 on you can also let swyh-rs do some buffering, what happens if you enable let's say a 100 msec buffer? Does the time before stuttering begins increase?

@dheijl dheijl added the question Further information is requested label May 19, 2024
@ibaraki-douji
Copy link

Hey, currently having the same issue, yes i'm also on wifi (both sonos and laptop).
Regarding your question setting an initial buffer did not change anything for me.

I can understand sometimes it's because i hit 100% CPU due to what i do, but most time after 15/45m the audio start to stutter more and more (if i keep the audio in stutter for 5m i then have bigger stutters of .5s without audio).

Also i don't think the wifi is busy as i'm alone with the sonos, my computer and my phone on it.

And to finish, i think the most probable cause is yes the sonos that gets desync due to something (maybe the clock, but idk how to check).

Maybe a test to check if it's the clock (replace the sonos with a pc/phone) :

  • Stream from a PC on WiFi
  • Use another PC/Phone and play the audio
  • Check if the stutter also occures in that case

@dheijl
Copy link
Owner

dheijl commented Jan 15, 2025

I'm afraid that the only thing you can do is a quick stop/start streaming in swyh-rs to get the Sonos in sync again.

@dheijl
Copy link
Owner

dheijl commented Jan 15, 2025

Question: are you streaming flac format, and if not, does using flac make any difference?

@ibaraki-douji
Copy link

Hi @dheijl , i wasn't using FLAC but WAV, i switched to FLAC and saw that for whatever reason there was an increasing delay between the pc audio and the sonos (at start .5s beacause buffer time, after 10m it was 5s delay). Sadly i wasn't able to listen for very long as people came visit me, but after 15m there was not stutter, i will keep you updated on this.

@dheijl
Copy link
Owner

dheijl commented Jan 16, 2025

As flac compresses the output an increase in the delay on startup is unavoidable.

But if the audio clocks on both devices are the same it should not increase after that.

So this seems to point to a difference in clock speed between the pc and the Sonos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants