Weird SDL2 hardware audio permission issue on GNU/Linux


I’m using rust-sdl2 (version 0.30.0) writing a SDL2 based app while learning both Rust and SDL2.
I get following error when I try to run it Arch based GNU/Linux distro:

$ RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/flipper`
INFO: Starting flipper
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Couldn\'t set hardware audio parameters: Operation not permitted"', /checkout/src/libcore/
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/
             at /checkout/src/libstd/
   3: std::panicking::default_hook
             at /checkout/src/libstd/
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/
   5: std::panicking::begin_panic
             at /checkout/src/libstd/
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/
   7: rust_begin_unwind
             at /checkout/src/libstd/
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/
   9: core::result::unwrap_failed
             at /checkout/src/libcore/
  10: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/
  11: flipper::main
             at src/
  12: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/
  13: std::rt::lang_start
             at /checkout/src/libstd/
             at /checkout/src/libstd/
             at /checkout/src/libstd/
  14: main
  15: __libc_start_main
  16: _start

Same code works fine on MacOS and used to work fine.

Sounds part used to work on my GNU/Linux system untill this comment:

Anyone had similar issues?
Thanks in advance.


I was able to run it after chaing AudioSpecDesired from 42100 to 44100 for white noise generation function.
But it doesn’t generate any white noise after that change.
I see following log message:
ALSA lib pcm.c:8323:(snd_pcm_recover) underrun occurred