dheijl / swyh-rs

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

Activating "Inject silence" leads to app not starting any more #107

Closed eikowagenknecht closed 1 year ago

eikowagenknecht commented 1 year ago

As the title says, after activating the file on the following application restart, the app window opens for a second and then closes again, process terminated.

I needed to set InjectSilence = false in the .toml config file to get the app to start again.

Not sure where to find the logs for the UI, but when I set the parameter in the CLI, the following is logged:

Args { dry_run: None, config_id: None, server_port: None, auto_resume: None, sound_source_index: None, log_level: None, ssdp_interval_mins: None, auto_reconnect: None, disable_chunked: None, use_wave_format: None, bits_per_sample: None, streaming_format: None, player_ip: None, ip_address: None, inject_silence: None }

Loading config from C:\Users\mail\.swyh-rs\config_cli.toml
09:32:46 [INFO] swyh-rs V 1.8.3 - Running on x86_64, windows, windows - Logging started.
09:32:46 [INFO] Config: Configuration { server_port: Some(5901), auto_resume: false, sound_source: "Logitech Headset (Logitech PRO X Wireless Gaming Headset)", sound_source_index: None, log_level: Info, ssdp_interval_mins: 10.0, auto_reconnect: true, disable_chunked: true, use_wave_format: false, bits_per_sample: Some(16), streaming_format: Some(Lpcm), monitor_rms: false, capture_timeout: Some(2000), inject_silence: Some(true), last_renderer: "Sonos Play:5 Büro - Sonos Play:5 Media Renderer", last_network: "192.168.40.110", config_dir: "C:\\Users\\mail\\.swyh-rs", config_id: Some("_cli") }
09:32:46 [INFO] Found Audio Source: index = 0, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:32:46 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:32:46 [INFO] Found Audio Source: index = 1, name = Beyerdynamic Kopfhörer (2- FiiO USB DAC-E10)
09:32:46 [INFO] Found Audio Source: index = 2, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:32:46 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:32:46 [INFO] Found Audio Source: index = 3, name = Logitech Webcam (2- Logitech Webcam C930e)
09:32:46 [INFO] Found network: 192.168.40.110
09:32:46 [INFO] Found network: 127.0.0.1
09:32:46 [INFO] Now running at ABOVE_NORMAL_PRIORITY_CLASS
09:32:46 [INFO] Capturing audio from: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:32:46 [INFO] Default audio SupportedStreamConfig { channels: 1, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:32:46 [INFO] Injecting silence into the output stream
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BackendSpecific { err: BackendSpecificError { description: "failed to build render client: 0x88890003" } }', src\utils\bincommon.rs:32:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

With RUST_BACKTRACE="full" and LOG_LEVEL="DEBUG":

09:38:02 [INFO] swyh-rs V 1.8.3 - Running on x86_64, windows, windows - Logging started.
09:38:02 [INFO] Config: Configuration { server_port: Some(5901), auto_resume: false, sound_source: "Logitech Headset (Logitech PRO X Wireless Gaming Headset)", sound_source_index: None, log_level: Debug, ssdp_interval_mins: 10.0, auto_reconnect: true, disable_chunked: true, use_wave_format: false, bits_per_sample: Some(16), streaming_format: Some(Lpcm), monitor_rms: false, capture_timeout: Some(2000), inject_silence: Some(true), last_renderer: "Sonos Play:5 Büro - Sonos Play:5 Media Renderer", last_network: "192.168.40.110", config_dir: "C:\\Users\\mail\\.swyh-rs", config_id: Some("_cli") }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices: Supported hosts:
  [Wasapi]
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices: Available hosts:
  [Wasapi]
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices: WASAPI
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   Default Output Device:
    Some("Logitech Headset (Logitech PRO X Wireless Gaming Headset)")
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   Default Input Device:
    Some("Logitech Headset (Logitech PRO X Wireless Gaming Headset)")
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   Devices:
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   1. "Logitech Headset (Logitech PRO X Wireless Gaming Headset)"
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     All supported output stream configs:
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:       1.1. SupportedStreamConfigRange { channels: 8, min_sample_rate: SampleRate(44100), max_sample_rate: SampleRate(44100), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     Default output stream config:
      SupportedStreamConfig { channels: 8, sample_rate: SampleRate(44100), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   2. "Beyerdynamic Kopfhörer (2- FiiO USB DAC-E10)"
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     All supported output stream configs:
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:       2.1. SupportedStreamConfigRange { channels: 2, min_sample_rate: SampleRate(48000), max_sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     Default output stream config:
      SupportedStreamConfig { channels: 2, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   3. "Logitech Headset (Logitech PRO X Wireless Gaming Headset)"
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     All supported input stream configs:
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:       3.1. SupportedStreamConfigRange { channels: 1, min_sample_rate: SampleRate(48000), max_sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     Default input stream config:
      SupportedStreamConfig { channels: 1, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:   4. "Logitech Webcam (2- Logitech Webcam C930e)"
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     All supported input stream configs:
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:       4.1. SupportedStreamConfigRange { channels: 2, min_sample_rate: SampleRate(48000), max_sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [DEBUG] (1) swyh_rs::utils::audiodevices:     Default input stream config:
      SupportedStreamConfig { channels: 2, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [INFO] Found Audio Source: index = 0, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Found Audio Source: index = 1, name = Beyerdynamic Kopfhörer (2- FiiO USB DAC-E10)
09:38:02 [INFO] Found Audio Source: index = 2, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Found Audio Source: index = 3, name = Logitech Webcam (2- Logitech Webcam C930e)
09:38:02 [INFO] Found network: 192.168.40.110
09:38:02 [INFO] Found network: 127.0.0.1
09:38:02 [INFO] Now running at ABOVE_NORMAL_PRIORITY_CLASS
09:38:02 [DEBUG] (1) swyh_rs_cli: Try capturing system audio
09:38:02 [INFO] Capturing audio from: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Default audio SupportedStreamConfig { channels: 1, sample_rate: SampleRate(48000), buffer_size: Range { min: 0, max: 4294967295 }, sample_format: F32 }
09:38:02 [INFO] Injecting silence into the output stream
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BackendSpecific { err: BackendSpecificError { description: "failed to build render client: 0x88890003" } }', src\utils\bincommon.rs:32:14
stack backtrace:
   0:     0x7ff6aab666f2 - <unknown>
   1:     0x7ff6aab8431b - <unknown>
   2:     0x7ff6aab6150a - <unknown>
   3:     0x7ff6aab6643b - <unknown>
   4:     0x7ff6aab68d2a - <unknown>
   5:     0x7ff6aab68990 - <unknown>
   6:     0x7ff6aab69406 - <unknown>
   7:     0x7ff6aab692fe - <unknown>
   8:     0x7ff6aab670b9 - <unknown>
   9:     0x7ff6aab69010 - <unknown>
  10:     0x7ff6aabeacc5 - <unknown>
  11:     0x7ff6aabeb1e6 - <unknown>
  12:     0x7ff6aaa163f4 - <unknown>
 09:38:02 [INFO] The wave_reader is now receiving samples
 13:     0x7ff6aa9c6955 - <unknown>
  14:     0x7ff6aa9cb106 - <unknown>
  15:     0x7ff6aa9cb49d - <unknown>
  16:     0x7ff6aab5b29e - <unknown>
  17:     0x7ff6aa9caefc - <unknown>
  18:     0x7ff6aabe02a0 - <unknown>
  19:     0x7ffd8a1426ad - BaseThreadInitThunk
  20:     0x7ffd8ad4aa68 - RtlUserThreadStart
eikowagenknecht commented 1 year ago

Switching around the input seems to add the line "SoundCardIndex = 0" to the TOML and then it works?

Crashing TOML:

[Configuration]
ServerPort = 5901
AutoResume = false
SoundCard = "Logitech Headset (Logitech PRO X Wireless Gaming Headset)"
LogLevel = "DEBUG"
SSDPIntervalMins = 10.0
AutoReconnect = true
DisableChunked = true
UseWaveFormat = false
BitsPerSample = 16
StreamingFormat = "Lpcm"
MonitorRms = false
CaptureTimeout = 2000
InjectSilence = true
LastRenderer = "Sonos Play:5 Büro - Sonos Play:5 Media Renderer"
LastNetwork = "192.168.40.110"
ConfigDir = 'C:\Users\mail\.swyh-rs'
ConfigId = "_cli"
dheijl commented 1 year ago

Thanks, I'll try-out to reproduce and fix it.

dheijl commented 1 year ago

I can not reproduce this using the GUI and starting without an existing config file. Can you describe how you can cause the crash when you start without an existing config file?

When you use the cli you are supposed to supply the options as commandline arguments, you're not supposed to edit the config toml.

One of the necessary options is the sound source index to select the correct sound card.

To get the necessary info you can run swyh-rs-cli -n -l info once.

When I run /swyh-rs-cli -l info -o 192.168.0.254 -S true -s 0 -f wav without an existing config file I don't get a crash.

I didn't try to edit the config file manually though.

But the sound source index should probably default to zero if you don't specify it, so I will change that.

eikowagenknecht commented 1 year ago

Interesting. I get that I should have passed parameters into the CLI instead of modifying the config file. But I only tried the CLI because the GUI kept crashing and I hoped to get more info fron the CLI about why the crash happened. And yes, I did not see the GUI log file in the same dir as the config.toml, otherwise I would have posted that and skipped a lot of the confusion I apparently caused, sorry

But in the GUI no parameters should be needed, right?

Since changing the sound source from A to B and then back again fixed the issue (and added the missing entry in the config) my guess would be that the mechanism that prepopulates the available audio devices on first start does not set the parameter to 0 but that manually switching the device later does so.

dheijl commented 1 year ago

My problem is that I can not reproduce it in the gui. The gui does not need parameters, but I can not get it to crash by enabling silence injection. It may be related to your hardware configuration (or not). The log files are in the same folder as the config file. If you could produce a crash with log level set to debug, and attach the complete resulting log file here, it may help me to pinpoint the bug...

eikowagenknecht commented 1 year ago

Sure, I‘ll do it next week (on vacation for the weekend).

dheijl commented 1 year ago

You are experiencing the problem because you have two audio devices with an identical name:

09:38:02 [INFO] Found Audio Source: index = 0, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)
...
09:38:02 [INFO] Found Audio Source: index = 2, name = Logitech Headset (Logitech PRO X Wireless Gaming Headset)
09:38:02 [INFO] Selected audio source: Logitech Headset (Logitech PRO X Wireless Gaming Headset)

Without a sound source index in the config the last one "wins" (and it does not support injecting silence, hence the panic).

The problem was introduced with PR#95 that adds listing input devices in addition to output devices. Previously these were not listed as possible sound sources, and they do not support injecting silence.

Now that the sound source index defaults to 0 it should no longer happen.

dheijl commented 1 year ago

Should be fixed in the new 1.8.4 release.

Can't really test it myself: I have no duplicate device names in my setup.

eikowagenknecht commented 1 year ago

Thank you, it works just fine now with the new version!

Just noticed one minor thing:

dheijl commented 1 year ago

Just noticed one minor thing:

  • The website says "The current release is 1.8.5", the application reports as 1.8.4 and the readme.md that is opened after the install says "The current release is 1.8.3".

Yes, I was a bit hasty to get the corrected release online. Sorry about that... Perhaps I should release 1.8.6 where everything is synced correctly.

dheijl commented 1 year ago

In fact only the setup and the readme were affected. I've corrected the readme and replaced the setup for 1.8.4. I hope I got it right this time.