Crash on FreeBSD + bitperfect USB audio
Describe the bug Crashes on every song.
To Reproduce
- Run the app.
- Play any song.
Expected behavior Standard play.
Screenshots

System (please complete the following information):
- OS: FreeBSD 13.1-RELEASE
- Terminal: any
- Version: 0.11.0
- Installed from: cargo + portaudio
Additional context Full Shiit 3 USB DAC
Same on FreeBSD 13.2-STABLE amd64 / FiiO KA5 USB DAC
ncspot 0.13.2 Audio backends: portaudio, pipe, subprocess
Tried to reproduce this on my FreeBSD 13.2 VM with a FiiO K7 BT USB DAC as I wanted to look into this and see whether it still happened on the latest version, but can't reproduce this on 0.11.0 or 0.13.2.
@ThomasFrans
Tested 0.13.4 on FreeBSD 15 CURRENT and same error.
Have you setup sysctl.conf:
# Enable bit-perfect playback for USB DAC
dev.pcm.4.bitperfect=1
# The recommended way to use bitperfect mode is to disable VCHANs
dev.pcm.4.play.vchans=0
or have run:
$ sysctl dev.pcm.4.bitperfect=1
$ sysctl dev.pcm.4.play.vchans=0
?
ncspot starts ok but crashes when playing a song.
Thanks
@ThomasFrans
Is there a way to debug this crash? I'm not an expert in rust and will need correct procedure how to debug it.
I missed the configuration for bit perfect audio. I'm new to BSD so I didn't know you had to set this manually. I'll try with that option set.
@ThomasFrans
See also:
man 4 sound
https://man.freebsd.org/cgi/man.cgi?query=sound&sektion=4&apropos=0&manpath=FreeBSD+13.2-RELEASE+and+Ports
Thanks
I can now recreate it. I don't think librespot supports this setup. I'll try to add more graceful handling of the error.
- version:
ncspot 1.0.0 (15515c2) - installed:
cargo run --no-default-features --features share_clipboard,portaudio_backend,mpris,notify,crossterm_backend - AMP/DAC: USB FiiO K7BT
debug backtrace
0: ncspot::panic::register_backtrace_panic_handler::{{closure}}
at ./src/panic.rs:20:38
1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
2: std::panicking::rust_panic_with_hook
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
3: std::panicking::begin_panic_handler::{{closure}}
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
4: std::sys_common::backtrace::__rust_end_short_backtrace
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
5: rust_begin_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
6: core::panicking::panic_fmt
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
7: core::result::unwrap_failed
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
8: core::result::Result<T,E>::unwrap
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23
9: <librespot_playback::audio_backend::portaudio::PortAudioSink as librespot_playback::audio_backend::Sink>::start
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/audio_backend/portaudio.rs:121:46
10: librespot_playback::player::PlayerInternal::ensure_sink_running
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/player.rs:1184:19
11: librespot_playback::player::PlayerInternal::start_playback
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/player.rs:1472:13
12: <librespot_playback::player::PlayerInternal as core::future::future::Future>::poll
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/player.rs:981:25
13: futures_executor::local_pool::block_on::{{closure}}
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.30/src/local_pool.rs:317:23
14: futures_executor::local_pool::run_executor::{{closure}}
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.30/src/local_pool.rs:90:37
15: std::thread::local::LocalKey<T>::try_with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
16: std::thread::local::LocalKey<T>::with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
17: futures_executor::local_pool::run_executor
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.30/src/local_pool.rs:86:5
18: futures_executor::local_pool::block_on
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.30/src/local_pool.rs:317:5
19: librespot_playback::player::Player::new::{{closure}}
at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/player.rs:384:13
20: std::sys_common::backtrace::__rust_begin_short_backtrace
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
21: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:529:17
22: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panic/unwind_safe.rs:272:9
23: std::panicking::try::do_call
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
24: __rust_try
25: std::panicking::try
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
26: std::panic::catch_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
27: std::thread::Builder::spawn_unchecked_::{{closure}}
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:528:30
28: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
29: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
31: std::sys::unix::thread::Thread::new::thread_start
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17
32: <unknown>
panicked at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-playback-0.4.2/src/audio_backend/portaudio.rs:121:46:
called `Result::unwrap()` on an `Err` value: Sample format not supported
@ThomasFrans
In that case this PR can be closed by https://github.com/hrkfdn/ncspot/commit/38010b4c7649797de03cb798700bd923340f61bc or should we do some more tests?
Thanks
I'd say so. I don't think much can be done here except for a more graceful exit.
Thanks everyone, will close it then :)