cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Panicking in the output callback causes ALSA output stream drop to panic

Open Ralith opened this issue 5 years ago • 2 comments

Example backtrace:

thread 'main' panicked at 'assertion failed: ret == 8', /home/ralith/.cargo/registry/src/github.com-1ecc6299db9ec823/cpal-0.12.1/src/host/alsa/mod.rs:130:9
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:497
   1: cpal::host::alsa::TriggerSender::wakeup
             at /home/ralith/.cargo/registry/src/github.com-1ecc6299db9ec823/cpal-0.12.1/src/host/alsa/mod.rs:130
   2: <cpal::host::alsa::Stream as core::ops::drop::Drop>::drop
             at /home/ralith/.cargo/registry/src/github.com-1ecc6299db9ec823/cpal-0.12.1/src/host/alsa/mod.rs:863
   3: core::ptr::drop_in_place
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ptr/mod.rs:184
   4: core::ptr::drop_in_place
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ptr/mod.rs:184
   5: core::ptr::drop_in_place
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ptr/mod.rs:184
   6: demo::main
             at ./examples/demo.rs:92
   7: core::ops::function::FnOnce::call_once
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ops/function.rs:227

I'm not sure what the best way to handle panics in the output callback is, but it looks like the current behavior isn't intended either.

Ralith avatar Oct 09 '20 03:10 Ralith

I think i'm getting the same error. I'm using rodio to play some streams from internet, which is using cpal and alsa. It's running on micro computer NanoPi Neo with Armv7 cpu. When i start playback after some inactivity(about 2-8h) cpal code panics:

thread 'main' panicked at 'assertion failed: `(left == right)`
Jun 27 18:54:28.035042 DietPi unitra-digital-rs[23877]:   left: `-1`,
Jun 27 18:54:28.035042 DietPi unitra-digital-rs[23877]:  right: `8`', /home/komp/.cargo/registry/src/github.com-1ecc6299db9ec823/cpal-0.15.1/src/host/alsa/mod.rs:145:9

My code is creating new default device and Sink in rodio.

My /etc/asound.conf :

pcm.!default {
    type plug
    slave.pcm "dmixer"
}

pcm.dmixer  {
    type dmix
    ipc_key 102434
    slave {
        pcm "hw:0,0"
        rate 44100
    }
    bindings {
        0 0
        1 1
    }
}

ctl.dmixer {
    type hw
    card 0
}

Any help will be appreciated.

dzubybb avatar Jun 27 '23 17:06 dzubybb