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 crash when default audio output device in use #2579

Closed
TheButlah opened this issue Jul 31, 2021 · 3 comments
Closed

audio crash when default audio output device in use #2579

TheButlah opened this issue Jul 31, 2021 · 3 comments
Labels
A-Audio Sounds playback and modification C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@TheButlah
Copy link

TheButlah commented Jul 31, 2021

Bevy version

0.5

Operating system & version

Windows 10

What you did

I use https://vb-audio.com/Voicemeeter/, a virtual audio mixer. It uses a virtual audio cable that i set as the default audio device to allow me to mix sounds and play things like spotify over my mic. I have never had issues with any programs not working with it, but today when I tried to run bevy while outputting to the same speaker that the audio mixer was supposed to be also outputting to, bevy crashed.

What you expected to happen

Bevy should have played audio through the speaker, and not crashed, or otherwise the virtual mixer should have played audio, and not crashed (perhaps depending on which had control of the speaker at the time?). The audio would not be sent to the mixer. This is how all other programs seem to work.

What actually happened

Bevy crashed:

thread 'main' panicked at 'build_output_stream failed with all supported formats: BackendSpecific { err: BackendSpecificError { description: "OS Error -2004287478 (FormatMessageW() returned error 15100) (os error -2004287478)" } }', C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.1\src\stream.rs:208:22stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\/library\core\src\panicking.rs:92
   2: core::result::unwrap_failed
             at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\/library\core\src\result.rs:1355
   3: core::result::Result<tuple<alloc::sync::Arc<rodio::dynamic_mixer::DynamicMixerController<f32>>, cpal::platform::platform_impl::Stream>, cpal::error::BuildStreamError>::expect<tuple<alloc::sync::Arc<rodio::dynamic_mixer::DynamicMixerController<f32>>, cpal:
             at C:\Users\Ryan\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs:997
   4: rodio::stream::{{impl}}::try_new_output_stream::{{closure}}
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.1\src\stream.rs:204
   5: core::result::Result<tuple<alloc::sync::Arc<rodio::dynamic_mixer::DynamicMixerController<f32>>, cpal::platform::platform_impl::Stream>, cpal::error::BuildStreamError>::unwrap_or_else<tuple<alloc::sync::Arc<rodio::dynamic_mixer::DynamicMixerController<f32>
             at C:\Users\Ryan\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs:821
   6: rodio::stream::{{impl}}::try_new_output_stream
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.1\src\stream.rs:200
   7: rodio::stream::OutputStream::try_from_device
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.1\src\stream.rs:31
   8: rodio::stream::OutputStream::try_default
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.1\src\stream.rs:45
   9: bevy_audio::audio_output::{{impl}}::default<bevy_audio::audio_source::AudioSource>
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_audio-0.5.0\src\audio_output.rs:22
  10: bevy_ecs::world::{{impl}}::from_world<bevy_audio::audio_output::AudioOutput<bevy_audio::audio_source::AudioSource>>
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\world\mod.rs:928
  11: bevy_app::app_builder::AppBuilder::init_non_send_resource<bevy_audio::audio_output::AudioOutput<bevy_audio::audio_source::AudioSource>>
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:272
  12: bevy_audio::{{impl}}::build
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_audio-0.5.0\src\lib.rs:23
  13: bevy_app::plugin_group::PluginGroupBuilder::finish
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\plugin_group.rs:104
  14: bevy_app::app_builder::AppBuilder::add_plugins<bevy_internal::default_plugins::DefaultPlugins>
             at C:\Users\Ryan\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:295
  15: slimevr_viewer::main
             at .\viewer\src\main.rs:5
  16: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\Ryan\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227

Additional information

The crash does not happen when the virtual audio cable is selected as the default audio output device. This is what should be selected anyway, as that would route bevy's audio through the mixer, and then from there into the speaker. However, what I didn't expect is that routing it directly into the speaker (by setting speaker as default audio device) would cause a crash. I assume this is due to some sort of exclusive access of the speaker by the virtual audio mixer? No other program seems to have this issue however - they play the sound normally

@TheButlah TheButlah added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 31, 2021
@alice-i-cecile alice-i-cecile added A-Audio Sounds playback and modification S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Jul 31, 2021
@TheButlah
Copy link
Author

Edit: using bevy 0.5 not 0.4

@orromis
Copy link

orromis commented Sep 28, 2021

Hello, it looks like this is already fixed (in this PR) on the main branch. Same thing is happening to me - I'm using headphone DAC and when I listen to music via Tidal I cannot run bevy app - it crashes with the same error message. The problem is that Tidal has exclusive control over the sound device and Windows behaves like it doesn't have sound device at all. When I try to run examples from main branch, it works, when I switch to release-0.5.1 (or when I run my project that uses 0.5) it crashes.

@SolarLiner
Copy link
Contributor

The panic should be fixed by #850, and I suspect the lack of available device is due to VoiceMeeter taking the speakers output in exclusive mode (using the WASAPI Exclusive Mode or the Kernel Streaming API), meaning that no other application can use it simultaneously.

Closing this as completed by the PR linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Audio Sounds playback and modification C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
Status: Done
Development

No branches or pull requests

4 participants