cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Trying to run bevy minimal example

Open TFCx opened this issue 3 years ago • 4 comments

I'm trying to compile a bevy minimal example...

use bevy::prelude::*;

fn main() {
    App::build().add_plugins(DefaultPlugins).run();

And i'm getting this error

$> ./conflict_cay.exe
thread 'main' panicked at 'build_output_stream failed with all supported formats: StreamConfigNotSupported', C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.0\src\stream.rs:202:22
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/bc39d4d9c514e5fdb40a5782e6ca08924f979c35\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/bc39d4d9c514e5fdb40a5782e6ca08924f979c35\/library\core\src\panicking.rs:92
   2: core::option::expect_none_failed
             at /rustc/bc39d4d9c514e5fdb40a5782e6ca08924f979c35\/library\core\src\option.rs:1266
   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\JD\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs:929
   4: rodio::stream::{{impl}}::new_output_stream::{{closure}}
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.0\src\stream.rs:198
   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\JD\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs:821
   6: rodio::stream::{{impl}}::new_output_stream
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.0\src\stream.rs:195
   7: rodio::stream::OutputStream::try_from_device
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.0\src\stream.rs:32
   8: rodio::stream::OutputStream::try_default
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\rodio-0.13.0\src\stream.rs:46
   9: bevy_audio::audio_output::{{impl}}::default<bevy_audio::audio_source::AudioSource>
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_audio-0.4.0\src\audio_output.rs:22
  10: bevy_ecs::resource::resources::{{impl}}::from_resources<bevy_audio::audio_output::AudioOutput<bevy_audio::audio_source::AudioSource>>
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.4.0\src\resource\resources.rs:346
  11: bevy_app::app_builder::AppBuilder::init_thread_local_resource<bevy_audio::audio_output::AudioOutput<bevy_audio::audio_source::AudioSource>>
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.4.0\src\app_builder.rs:248
  12: bevy_audio::{{impl}}::build
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_audio-0.4.0\src\lib.rs:23
  13: bevy_app::plugin_group::PluginGroupBuilder::finish
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.4.0\src\plugin_group.rs:104
  14: bevy_app::app_builder::AppBuilder::add_plugins<bevy_internal::default_plugins::DefaultPlugins>
             at C:\Users\JD\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.4.0\src\app_builder.rs:271
  15: conflict_cay::main
             at D:\Code\conflict_cay\src\main.rs:4
  16: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\JD\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Can I provide more information?

TFCx avatar Jan 17 '21 01:01 TFCx

Do you have jack running? The alsa backend of cpal doesn't seem to never return this error.

bjorn3 avatar Jan 17 '21 13:01 bjorn3

I'm on Win10, so I guess no Alsa, nor JACK? It should go through WASAPI, right ? (i'm in no way familiar with audio drivers :/ )

(anyway, thanks for the quick answer @bjorn3 :) )

TFCx avatar Jan 17 '21 14:01 TFCx

I'm on Win10, so I guess no Alsa, nor JACK?

My bad. Should have looked at the file paths in the backtrace. Windows uses wasapi by default:

https://github.com/RustAudio/cpal/blob/f8775b1e7bb9b1ad9798b449202c7f53703220d9/src/platform/mod.rs#L551-L556

There are six locations at which this error can happen. Just search for StreamConfigNotSupported in https://github.com/RustAudio/cpal/blob/70408a92ec78533ed275a90e55415041f94c1874/src/host/wasapi/device.rs I think it may be useful to figure out which one is responsible. You could patch cpal to add a debug message before returning the error at each location or you could set a breakpoint at each location. For those with .ok_or(BuildStreamError::StreamConfigNotSupported)? you may need to singlestep a few times to see if it actually returns an error or not.

(disclaimer: not a dev of cpal. this is the first time I look at the codebase)

bjorn3 avatar Jan 17 '21 17:01 bjorn3

Ok. I've tracing the calls: bevy uses a bevy_audio crate, that uses a rodio crate that uses cpal.

The cpal error seems to emerge here: image

Does anything seems strange to anyone? (like the audio format description?)

TFCx avatar Jan 17 '21 22:01 TFCx