Merge pull request #648 from kaihagseth/fix/follow-default-osx
fix: follow default output source on mac osx
This commit is contained in:
commit
9748543025
2 changed files with 16 additions and 3 deletions
|
|
@ -83,6 +83,7 @@ impl Iterator for Devices {
|
|||
fn next(&mut self) -> Option<Device> {
|
||||
self.0.next().map(|id| Device {
|
||||
audio_device_id: id,
|
||||
is_default: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +111,10 @@ pub fn default_input_device() -> Option<Device> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let device = Device { audio_device_id };
|
||||
let device = Device {
|
||||
audio_device_id,
|
||||
is_default: true,
|
||||
};
|
||||
Some(device)
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +141,10 @@ pub fn default_output_device() -> Option<Device> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let device = Device { audio_device_id };
|
||||
let device = Device {
|
||||
audio_device_id,
|
||||
is_default: true,
|
||||
};
|
||||
Some(device)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ impl DeviceTrait for Device {
|
|||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Device {
|
||||
pub(crate) audio_device_id: AudioDeviceID,
|
||||
is_default: bool,
|
||||
}
|
||||
|
||||
impl Device {
|
||||
|
|
@ -421,7 +422,12 @@ struct StreamInner {
|
|||
}
|
||||
|
||||
fn audio_unit_from_device(device: &Device, input: bool) -> Result<AudioUnit, coreaudio::Error> {
|
||||
let mut audio_unit = AudioUnit::new(coreaudio::audio_unit::IOType::HalOutput)?;
|
||||
let output_type = if device.is_default && !input {
|
||||
coreaudio::audio_unit::IOType::DefaultOutput
|
||||
} else {
|
||||
coreaudio::audio_unit::IOType::HalOutput
|
||||
};
|
||||
let mut audio_unit = AudioUnit::new(output_type)?;
|
||||
|
||||
if input {
|
||||
// Enable input processing.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue