RustAudio / coreaudio-rs

A friendly rust interface to Apple's Core Audio API.
Apache License 2.0
203 stars 38 forks source link

Device input channels incorrectly reported in StreamFormat. #98

Closed npes-95 closed 1 year ago

npes-95 commented 1 year ago

Hi,

I've noticed a device's default number of input channels isn't correctly reported when querying StreamFormat. The number of output channels on the other hand is correctly reported.

You can reproduce this behaviour by running:

use coreaudio::audio_unit::macos_helpers::{audio_unit_from_device_id, get_device_id_from_name};

use std::env;

fn main() {
    let args: Vec<String> = env::args().collect();
    let device = &args[1];
    let au_in = audio_unit_from_device_id(get_device_id_from_name(device).unwrap(), true).unwrap();
    let au_out =
        audio_unit_from_device_id(get_device_id_from_name(device).unwrap(), false).unwrap();

    println!(
        "{} Input {:?}",
        device,
        au_in.input_stream_format().unwrap()
    );
    println!(
        "{} Output {:?}",
        device,
        au_out.output_stream_format().unwrap()
    );
}

Running with UMC1820 (10 in, 12 out) returns:

UMC1820 Input StreamFormat { sample_rate: 44100.0, sample_format: F32, flags: IS_FLOAT | IS_PACKED | IS_NON_INTERLEAVED, channels: 2 }
UMC1820 Output StreamFormat { sample_rate: 44100.0, sample_format: F32, flags: IS_FLOAT | IS_PACKED, channels: 12 }

I'm not sure whether this is an issue with the library or CoreAudio itself, so any help with this would be appreciated!

npes-95 commented 1 year ago

Looks like the issue is between the keyboard and chair, input_stream_format returns the current format, rather than the supported format(s). Will close as no longer relevant.