dheijl / swyh-rs

Stream What You Hear written in rust, inspired by SWYH.
MIT License
348 stars 15 forks source link

Are there any low-latency alternative software options for Mac OS? #104

Open luojiego opened 1 year ago

luojiego commented 1 year ago

About a year ago, I started experimenting with swyh-rs and noticed some latency on Windows. At that time, I felt it was acceptable as long as I could listen to music normally. However, recently I found that it's almost latency-free on Windows, making it suitable for watching videos or movies without any lag. But on Mac OS, I haven't come across software that's as efficient. I'm curious about what alternative software people use on Mac? Or is there any plan to adapt it for Mac?

dheijl commented 1 year ago

I'm sorry but I don't have a Mac so I can't adapt it myself, and I know nothing about Mac software...

luojiego commented 1 year ago

Thank you for your response. I sought help in the Sonos subreddit but found that the latency is too significant to ignore. I believe I'll use Windows to watch movies.

Nosh118 commented 1 year ago

Hi there - I appreciate that @dheijl doesn't have a mac, but I managed to successfully build swyh-rs on mac, but I keep receiving this error and no upnp devices are found. Do you have any idea on how I could possibly remedy this?

[ERROR] *E*E>Error reading SSDP M-SEARCH response: Resource temporarily unavailable (os error 35)
17:04:29 [ERROR] No renderers found!!!
Error: -1
dheijl commented 1 year ago

Apparently the MAC returns a non-standard error code for EAGAIN:

in src/rendercontrol.rs at line 561:

            Err(e) => {
                // ignore socket read timeout on Windows or EAGAIN on Linux
                if !(e.to_string().contains("10060") || e.to_string().contains("os error 11")) {
                    logger(format!("*E*E>Error reading SSDP M-SEARCH response: {e}"));
                }
            }

I suppose that adding an additional check for "os error 35" here could solve it. Could you try this?

Nosh118 commented 1 year ago

Could you send across a specific code block to paste in? not very well versed in rust or error handling unfortunately

dheijl commented 1 year ago

I applied the change on Github, so you can use the current master. But this is the changed code:

Err(e) => {
                // ignore socket read timeout on Windows or EAGAIN/EWOULBLOCK on Linux/Unix/MacOS
                if !(e.to_string().contains("10060")
                    || e.to_string().contains("os error 11")
                    || e.to_string().contains("os error 35"))
                {
                    logger(format!("*E*E>Error reading SSDP M-SEARCH response: {e}"));
                }
            }
Nosh118 commented 1 year ago

Thank you very much! Will report back once I rebuild.

Nosh118 commented 1 year ago

Thank you @dheijl, that has resolved that error, although no devices are showing in the list, just as before. I have tried running with sudo and manually allowing through the firewall.

No worries if this isn't something you're able to solve though, I know you don't have a mac!

dheijl commented 1 year ago

Can you run it with log level debug, and then attach the log file here? Or did you check already in the log that no devices are responding to the ssdp query?

Nosh118 commented 1 year ago
18:11:49 [DEBUG] (1) swyh_rs_cli: Try capturing system audio
18:11:49 [INFO] Capturing audio from: MacBook Pro Speakers
18:11:49 [INFO] Default audio SupportedStreamConfig { channels: 2, sample_rate: SampleRate(44100), buffer_size: Range { min: 14, max: 4096 }, sample_format: F32 }
18:11:49 [INFO] Discover networks
18:11:49 [INFO] Starting SSDP discovery
18:11:49 [INFO] The streaming server is listening on http://192.168.1.71:5901/stream/swyh.wav
18:11:49 [DEBUG] (3) swyh_rs::openhome::rendercontrol: SSDP discovery started
18:11:49 [INFO] Streaming sample rate: 44100, bits per sample: 16, format: LPCM
18:11:49 [DEBUG] (4) tiny_http: Server listening on 192.168.1.71:5901
18:11:49 [DEBUG] (5) tiny_http: Running accept thread
18:11:52 [DEBUG] (3) swyh_rs::openhome::rendercontrol: Getting new renderer descriptions
18:11:52 [DEBUG] (3) swyh_rs::openhome::rendercontrol: SSDP discovery complete
18:11:54 [ERROR] No renderers found!!!
Error: -1
dheijl commented 1 year ago

Thanks, but:

Can you attach the complete log file using the GitHub drag and drop feature?

But anyway it looks like the SSDP responses from UPNP devices are not getting through. Other programs seem to have similar problems using UDP on recent MAC OS versions according to Reddit ...

dheijl commented 1 year ago

Perhaps this explains it:

https://forum.xojo.com/t/big-sur-udp-broadcast-not-working-normally/58832

So goodbye to open source on MAC OS if this is true.

Nosh118 commented 1 year ago

From what I read, it still looks possible - just with a couple of extra caveats. Completely understand why you might not want to put the effort into adapting this though, just a shame I can't find anything near as good as this project for macOS!

dheijl commented 1 year ago

Feel free to add anything needed and make a pull request if you get it to work!

Nosh118 commented 1 year ago

Thanks, but:

  • debug logging is not activated (-l debug)
  • this is not the complete log file, just an excerpt

Can you attach the complete log file using the GitHub drag and drop feature?

But anyway it looks like the SSDP responses from UPNP devices are not getting through. Other programs seem to have similar problems using UDP on recent MAC OS versions according to Reddit ...

Sorry - missed this, have tried running with -l debug now and I'm not sure where the log file is saved to.

dheijl commented 1 year ago

It should be in a .swyhr-rs folder in your home directory, if such a thing exists on a MAC.

Nosh118 commented 1 year ago

Found the folder, but can’t seem to find any log files unfortunately.

dheijl commented 1 year ago

Anyway, let's keep this open in the hope that someone with Mac and Rust knowledge is prepared to help...