stijnvdb88 / Snap.Net

A cross-platform control client and player for https://github.com/badaix/snapcast
GNU General Public License v3.0
119 stars 11 forks source link

[Bug] Snap.Net iOS crashes when listening to audio stream that is not the default sampleformat (48k) #52

Open woliver99 opened 4 months ago

woliver99 commented 4 months ago

I have a Snapcast server running on my Android with Termux. I also have Librespot running on my Android with root. Here is what I'm using: https://github.com/woliver99/snapcast-termux So what I have Librespot do is pipe its audio out to a .pcm file and have Snapcast read the file.

And it seems that anytime I have the iOS app listening to the Librespot stream without fail it seems to crash after about 3 seconds.

But if I try to broadcast from the snap.net app on Android it works without any issues.

I haven't had time to debug further since I'm a bit busy at the moment but I'm using my own local iOS installation from the repo.

Once I find some more time il update the issue with my findings.

I have a feeling it might have something to do with it not being configured to accept pipe audio and causing a timeout with iOS's very strict runtime (iOS watchdog) since it might be blocking the main thread for a second or too long so it terminates it. The stream works on the Android and PC versions of snap.net with no problem.

Here is the log of me listening to my phone snap.net broadcast then switching to the Librespot stream: visual_studio_log.txt

woliver99 commented 3 months ago

Alright, I found what causes the crash. If the sampleformat is not the default, so 48k it will cause the iOS client to crash.

Here is what I changed in the snapserver config to get it to work, the only downside is that now the librespot stream sounds high-pitched since it's not the proper format:

source = pipe://{BASE_DIR}/pipe/librespot.pcm?name=Spotify&mode=create&sampleformat=44100:16:2 #Broken
source = pipe://{BASE_DIR}/pipe/librespot.pcm?name=Spotify&mode=create #Working