fix: follow default output source on mac osx
When playing out on default output source, follow the default output source chosen in sound preferences in osx.
This commit is contained in:
parent
bf026fe082
commit
d50e0ecbac
2 changed files with 16 additions and 3 deletions
|
|
@ -83,6 +83,7 @@ impl Iterator for Devices {
|
||||||
fn next(&mut self) -> Option<Device> {
|
fn next(&mut self) -> Option<Device> {
|
||||||
self.0.next().map(|id| Device {
|
self.0.next().map(|id| Device {
|
||||||
audio_device_id: id,
|
audio_device_id: id,
|
||||||
|
is_default: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +111,10 @@ pub fn default_input_device() -> Option<Device> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let device = Device { audio_device_id };
|
let device = Device {
|
||||||
|
audio_device_id,
|
||||||
|
is_default: true,
|
||||||
|
};
|
||||||
Some(device)
|
Some(device)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +141,10 @@ pub fn default_output_device() -> Option<Device> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let device = Device { audio_device_id };
|
let device = Device {
|
||||||
|
audio_device_id,
|
||||||
|
is_default: true,
|
||||||
|
};
|
||||||
Some(device)
|
Some(device)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ impl DeviceTrait for Device {
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
pub(crate) audio_device_id: AudioDeviceID,
|
pub(crate) audio_device_id: AudioDeviceID,
|
||||||
|
is_default: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
impl Device {
|
||||||
|
|
@ -421,7 +422,12 @@ struct StreamInner {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn audio_unit_from_device(device: &Device, input: bool) -> Result<AudioUnit, coreaudio::Error> {
|
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 {
|
if input {
|
||||||
// Enable input processing.
|
// Enable input processing.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue