ardaku / wavy

Asynchronous cross-platform real-time audio recording & playback.
https://docs.rs/crate/wavy/latest
Apache License 2.0
84 stars 4 forks source link

[Bug] Default USB-Audio Card #17

Closed pvitaliy84 closed 3 years ago

pvitaliy84 commented 3 years ago

New ticket.

uname -a Linux archlinux 5.9.8-arch1-1 #1 SMP PREEMPT Tue, 10 Nov 2020 22:44:11 +0000 x86_64 GNU/Linux

aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 0: CX20561 Analog [CX20561 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 1: CX20561 Digital [CX20561 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

cat /etc/asound.conf

pcm.!default {
   type hw
   card 0
}
ctl.!default {
   type hw
   card 0
}

cargo run --example record

    Finished dev [unoptimized + debuginfo] target(s) in 1.07s
     Running `target/debug/examples/record`
thread '<unnamed>' panicked at 'Speaker configuration failed', src/ffi/linux/ffi.rs:93:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any', /home/kolibrit/.cargo/registry/src/github.com-1ecc6299db9ec823/pasts-0.5.0/src/executor.rs:261:44
AldaronLau commented 3 years ago

@pvitaliy84 I think this is happening because you set your "USB PnP Sound Device" as the default audio device, but it's a microphone - and wavy is trying to connect to it as if it's a speaker, which is failing (since the record example records and plays back at the same time). I think I'll have to implement a microphone selector API in order to fix this bug. I'm not sure if there's a way to configure ALSA to get around this issue, but I'd guess that there is.

pvitaliy84 commented 3 years ago

Thanks. It will be good. And one moment yet: USB-Card may be unplugged. It will raise uncontrolled panic in a app

AldaronLau commented 3 years ago

@pvitaliy84 Thanks, I'll try to make sure that panics won't happen in that situation anymore when I make those changes.

AldaronLau commented 3 years ago

@pvitaliy84 I just released wavy 0.6.0 with fixes and a new API for selecting microphones and speakers. I believe this issue is fixed, so I'm closing it.