hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.
BSD 2-Clause "Simplified" License
4.96k stars 206 forks source link

Crash on FreeBSD + bitperfect USB audio #931

Closed cartesius68 closed 7 months ago

cartesius68 commented 2 years ago

Describe the bug Crashes on every song.

To Reproduce

  1. Run the app.
  2. Play any song.

Expected behavior Standard play.

Screenshots Screenshot_20220905_203558

System (please complete the following information):

Additional context Full Shiit 3 USB DAC

nunotexbsd commented 1 year ago

Same on FreeBSD 13.2-STABLE amd64 / FiiO KA5 USB DAC

ncspot 0.13.2 Audio backends: portaudio, pipe, subprocess

ThomasFrans commented 11 months ago

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.

nunotexbsd commented 11 months ago

@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

nunotexbsd commented 11 months ago

@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.

ThomasFrans commented 11 months ago

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.

nunotexbsd commented 11 months ago

@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

ThomasFrans commented 8 months ago

I can now recreate it. I don't think librespot supports this setup. I'll try to add more graceful handling of the error.

debug backtrace ``` 0: ncspot::panic::register_backtrace_panic_handler::{{closure}} at ./src/panic.rs:20:38 1: as core::ops::function::Fn>::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::unwrap at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23 9: ::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: ::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::try_with at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16 16: std::thread::local::LocalKey::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: 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: as core::ops::function::FnOnce>::call_once at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9 30: as core::ops::function::FnOnce>::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: 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 ```
nunotexbsd commented 7 months ago

@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

ThomasFrans commented 7 months ago

I'd say so. I don't think much can be done here except for a more graceful exit.

hrkfdn commented 7 months ago

Thanks everyone, will close it then :)