Closed arjenzhou closed 2 years ago
It's seems fail to get the default audio device name.
I used let endpoint = rodio::default_output_device().expect("Failed to find default music endpoint");
as my player endpoint. It works on my mac. default_output_device function try to find the available sounds device on your system.
In my case this happens on macOS Mojave when I use my August EP650 headphones via bluetooth, but I fear this is a general issue.
I don't connect any devices through bluetooth and, when run release it throws src/libcore/result.rs:1165:5
not rodio-0.10.0/src/engine.rs:113:32
I check the source code. and I think rodio use the cpal as dependence
/// The default output audio device on the system.
///
/// Returns `None` if no output device is available.
#[inline]
pub fn default_output_device() -> Option<Device> {
cpal::default_host().default_output_device()
}
fn default_output_device(&self) -> Option<Self::Device> {
match self.0 {
$(
HostInner::$HostVariant(ref h) => {
h.default_output_device().map(DeviceInner::$HostVariant).map(Device)
}
)*
}
}
If no output audio device on the system. will get null string and panic. so I think your can make a demo to check cpal default_output_device func works on your system, maybe like this?
use cpal::traits::HostTrait;
use cpal::traits::DeviceTrait;
fn main() {
let host = cpal::default_host();
let device = host.default_output_device().expect("no output device available");
println!("{:#?}", device.name());
}
I am new to Rust, and it seems like Device.name()
throws exception:
$ cargo run
Compiling foo v0.1.0 (/Users/zhouyang/repos/rust)
Finished dev [unoptimized + debuginfo] target(s) in 0.35s
Running `target/debug/foo`
Err(
BackendSpecific {
err: BackendSpecificError {
description: "core foundation unexpectedly returned null string",
},
},
)
which defined in https://docs.rs/cpal/0.11.0/src/cpal/platform/mod.rs.html#216-222
impl crate::traits::DeviceTrait for Device {
type SupportedInputFormats = SupportedInputFormats;
type SupportedOutputFormats = SupportedOutputFormats;
fn name(&self) -> Result<String, crate::DeviceNameError> {
match self.0 {
$(
DeviceInner::$HostVariant(ref d) => d.name(),
)*
}
}
...
}
Maybe brew install portaudio
will helps
Doesn't work :(
https://github.com/RustAudio/cpal/issues/385 And here is the detailed stacktrace.
macos 10.15.7 也出现了
Same problem here. Error message:
> ncmt
thread 'main' panicked at 'failed to read response: Custom { kind: InvalidData, error: "stream did notcontain valid UTF-8" }', src/api.rs:196:14
System info: Manjaro 20.2.1, Linux Kernel 5.10.15 ncmt version: 0.1.2
Same problem here. Error message:
> ncmt
thread 'main' panicked at 'failed to read response: Custom { kind: InvalidData, error: "stream did notcontain valid UTF-8" }', src/api.rs:196:14
System info: Manjaro 20.2.1, Linux Kernel 5.10.15 ncmt version: 0.1.2
And fix it in ncmt version: 0.1.3
environment:
I have tried run releases which throws
Then I tried build from source code, got