Introduce a process-wide singleton Queue

This will be the root queue for all platform audio operations
This commit is contained in:
Andreas Pehrson 2024-03-07 08:55:57 +01:00 коммит произвёл Andreas Pehrson
Родитель 147de1e6c8
Коммит 247b568e25
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -5,6 +5,14 @@ use std::mem;
use std::os::raw::c_void;
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
pub const DISPATCH_QUEUE_LABEL: &str = "org.mozilla.cubeb";
pub fn get_serial_queue_singleton() -> &'static Queue {
static SERIAL_QUEUE: OnceLock<Queue> = OnceLock::new();
SERIAL_QUEUE.get_or_init(|| Queue::new(DISPATCH_QUEUE_LABEL))
}
// Queue: A wrapper around `dispatch_queue_t` that is always serial.
// ------------------------------------------------------------------------------------------------
@ -197,6 +205,9 @@ impl Clone for Queue {
}
}
unsafe impl Send for Queue {}
unsafe impl Sync for Queue {}
#[test]
fn run_tasks_in_order() {
let mut visited = Vec::<u32>::new();

Просмотреть файл

@ -54,7 +54,6 @@ const NO_ERR: OSStatus = 0;
const AU_OUT_BUS: AudioUnitElement = 0;
const AU_IN_BUS: AudioUnitElement = 1;
const DISPATCH_QUEUE_LABEL: &str = "org.mozilla.cubeb";
const PRIVATE_AGGREGATE_DEVICE_NAME: &str = "CubebAggregateDevice";
const VOICEPROCESSING_AGGREGATE_DEVICE_NAME: &str = "VPAUAggregateAudioDevice";