not-fl3 / quad-snd

Cross-platform audio for Rust
110 stars 26 forks source link

Panicked at 'Can't set rate.' when using jack/alsa with a sample rate other than 44100 #49

Open wasolili opened 1 year ago

wasolili commented 1 year ago

I'm running on Linux using Jack for audio and using the default ALSA -> JACK plugin for the bridge (no Pulseaudio, no Pipewire) at a sample rate of 48000. This causes a thread '<unnamed>' panicked at 'Can't set rate.', src/alsa_snd.rs:57:9 error when I run the example code.

A workaround is changing my jack configuration to use a sample rate of 44100.

The full stacktrace is below:

$ cargo run --example simple
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/examples/simple`
thread '<unnamed>' panicked at 'Can't set rate.', src/alsa_snd.rs:57:9
stack backtrace:
   0:     0x55d265bf2140 - std::backtrace_rs::backtrace::libunwind::trace::h1d00f3fcf4cb5ac4
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55d265bf2140 - std::backtrace_rs::backtrace::trace_unsynchronized::h920a6ff332484ee2
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55d265bf2140 - std::sys_common::backtrace::_print_fmt::hd7323920c925af6d
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55d265bf2140 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3155a8c966b4beb5
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55d265c0cd2e - core::fmt::write::h062c617411b691df
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/fmt/mod.rs:1209:17
   5:     0x55d265bf0165 - std::io::Write::write_fmt::hb61fdf1275c61e1c
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/io/mod.rs:1682:15
   6:     0x55d265bf1f05 - std::sys_common::backtrace::_print::hd1b4d9664ab500e0
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55d265bf1f05 - std::sys_common::backtrace::print::hca896ae22beb06cb
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55d265bf378f - std::panicking::default_hook::{{closure}}::h0b5eeed5cf36ab5f
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:267:22
   9:     0x55d265bf34ca - std::panicking::default_hook::h8932b573145a321b
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:286:9
  10:     0x55d265bf3e88 - std::panicking::rust_panic_with_hook::h4b1447a24e3e94f8
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:688:13
  11:     0x55d265bd9408 - std::panicking::begin_panic::{{closure}}::h589a3bf2d2644459
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:608:9
  12:     0x55d265bd9726 - std::sys_common::backtrace::__rust_end_short_backtrace::he559fabaf885b24d
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x55d265bd9340 - std::panicking::begin_panic::h008fb3d754feeedd
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:607:12
  14:     0x55d265b1fb4b - quad_snd::snd::setup_pcm_device::h7f73e85bfcf806df
                               at /home/n/Projects/rust/quad-snd/src/alsa_snd.rs:57:9
  15:     0x55d265b1fd72 - quad_snd::snd::audio_thread::h86b2012b14fa8cf9
                               at /home/n/Projects/rust/quad-snd/src/alsa_snd.rs:104:22
  16:     0x55d265b51294 - quad_snd::snd::AudioContext::new::{{closure}}::h68fd989d4cc78137
                               at /home/n/Projects/rust/quad-snd/src/alsa_snd.rs:160:13
  17:     0x55d265b52ea3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hcf333de2932cddba
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:121:18
  18:     0x55d265b30fd4 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h05535e2e84fe1fb2
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/thread/mod.rs:551:17
  19:     0x55d265b60f24 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h210f370aefd641b1
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panic/unwind_safe.rs:271:9
  20:     0x55d265b52ce6 - std::panicking::try::do_call::h056daec0624d5620
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:483:40
  21:     0x55d265b52e6b - __rust_try
  22:     0x55d265b52b7b - std::panicking::try::h77960d6c0f4026df
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:447:19
  23:     0x55d265b4e294 - std::panic::catch_unwind::h864133c4dbdc14e5
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panic.rs:137:14
  24:     0x55d265b30de1 - std::thread::Builder::spawn_unchecked_::{{closure}}::hb7376751fe54742b
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/thread/mod.rs:550:30
  25:     0x55d265b27c9f - core::ops::function::FnOnce::call_once{{vtable.shim}}::h9543f2293c6ebf61
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/ops/function.rs:251:5
  26:     0x55d265bf62c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6202d10b0224e7b0
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/boxed.rs:1987:9
  27:     0x55d265bf62c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4dbea73c9cec160b
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/boxed.rs:1987:9
  28:     0x55d265bf62c3 - std::sys::unix::thread::Thread::new::thread_start::h0a2f4c32ba2f2278
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys/unix/thread.rs:108
:17
  29:     0x7feedc99c8fd - <unknown>
  30:     0x7feedca1ed20 - <unknown>
  31:                0x0 - <unknown>
Audio thread died
Audio thread died
Audio thread died
Audio thread died
mrlogick commented 1 year ago

Same error for me too, I'm using pipewire:

$ cargo run --release --example simple
thread '<unnamed>' panicked at 'Can't set rate.', src/alsa_snd.rs:57:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
TomLebeda commented 1 year ago

Same for me too, I'm using pulseaudio on Manjaro.

tylerdq commented 5 days ago

I'm having the same issue. Is there any hope of a more permanent solution?