betta-cyber / netease-music-tui

netease cloud music terminal client by rust :zap:
MIT License
420 stars 34 forks source link

Failed to run ncmt #10

Closed arjenzhou closed 2 years ago

arjenzhou commented 4 years ago

environment:

I have tried run releases which throws

thread 'main' panicked at 'No device name: BackendSpecific { err: BackendSpecificError { description: "core foundation unexpectedly returned null string" } }', src/libcore/result.rs:1165:5

Then I tried build from source code, got

thread 'main' panicked at 'No device name: BackendSpecific { err: BackendSpecificError { description: "core foundation unexpectedly returned null string" } }', /Users/abc/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.10.0/src/engine.rs:113:32
betta-cyber commented 4 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.

betta-cyber commented 4 years ago

https://github.com/RustAudio/rodio/issues/279

arjenzhou commented 4 years ago

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

betta-cyber commented 4 years ago

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());
}
arjenzhou commented 4 years ago

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(),
            )*
        }
    }
    ...
}
betta-cyber commented 4 years ago

Maybe brew install portaudio will helps

arjenzhou commented 4 years ago

Doesn't work :(

arjenzhou commented 4 years ago

https://github.com/RustAudio/cpal/issues/385 And here is the detailed stacktrace.

edifierx666 commented 3 years ago

macos 10.15.7 也出现了

MrAru commented 3 years ago

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

betta-cyber commented 3 years ago

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

22

And fix it in ncmt version: 0.1.3