Implement set_notification_runloop
This commit is contained in:
Родитель
afac52b8a0
Коммит
7ff946e644
|
@ -217,6 +217,24 @@ impl Into<ChannelLayout> for CAChannelLabel {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_notification_runloop() {
|
||||
let address = AudioObjectPropertyAddress {
|
||||
mSelector: kAudioHardwarePropertyRunLoop,
|
||||
mScope: kAudioObjectPropertyScopeGlobal,
|
||||
mElement: kAudioObjectPropertyElementMaster,
|
||||
};
|
||||
|
||||
// Ask HAL to manage its own thread for notification by setting the run_loop to NULL.
|
||||
// Otherwise HAL may use main thread to fire notifications.
|
||||
let run_loop: CFRunLoopRef = ptr::null_mut();
|
||||
let size = mem::size_of::<CFRunLoopRef>();
|
||||
let status =
|
||||
audio_object_set_property_data(kAudioObjectSystemObject, &address, size, &run_loop);
|
||||
if status != NO_ERR {
|
||||
cubeb_log!("Could not make global CoreAudio notifications use their own thread.");
|
||||
}
|
||||
}
|
||||
|
||||
fn audiounit_make_silent(io_data: &mut AudioBuffer) {
|
||||
assert!(!io_data.mData.is_null());
|
||||
let bytes = unsafe {
|
||||
|
@ -2243,6 +2261,7 @@ impl AudioUnitContext {
|
|||
|
||||
impl ContextOps for AudioUnitContext {
|
||||
fn init(_context_name: Option<&CStr>) -> Result<Context> {
|
||||
set_notification_runloop();
|
||||
let mut ctx = Box::new(AudioUnitContext::new());
|
||||
ctx.init();
|
||||
Ok(unsafe { Context::from_ptr(Box::into_raw(ctx) as *mut _) })
|
||||
|
|
Загрузка…
Ссылка в новой задаче