use super::*;
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct AudioOutputConfig {
#[get(type(copy))]
pub(crate) sample_rate_hz: u32,
#[get(type(copy))]
pub(crate) channels: u16,
#[get(type(copy))]
pub(crate) ring_frames: usize,
#[get(type(copy))]
pub(crate) max_voices: usize,
#[get(type(copy))]
pub(crate) master_gain: f32,
}
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct AudioOutputMetrics {
#[get(type(copy))]
pub(crate) driver_kind: AudioDriverKind,
#[get(type(copy))]
pub(crate) state: AudioOutputState,
#[get(type(copy))]
pub(crate) active_voices: usize,
#[get(type(copy))]
pub(crate) frames_mixed: u64,
#[get(type(copy))]
pub(crate) commands_ingested: u64,
#[get(type(copy))]
pub(crate) ring_buffered_frames: usize,
#[get(type(copy))]
pub(crate) ring_underruns: u64,
#[get(type(copy))]
pub(crate) ring_overruns: u64,
#[get(type(copy))]
pub(crate) clipped_samples: u64,
#[get(type(copy))]
pub(crate) peak_amplitude: f32,
}
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct AudioSynthVoice {
#[get(type(copy))]
pub(crate) cue: SoundCue,
#[get(type(copy))]
pub(crate) left_gain: f32,
#[get(type(copy))]
pub(crate) right_gain: f32,
#[get(type(copy))]
pub(crate) pitch: f32,
#[get(type(copy))]
pub(crate) phase: f32,
#[get(type(copy))]
pub(crate) elapsed_frames: u32,
#[get(type(copy))]
pub(crate) duration_frames: u32,
#[get(type(copy))]
pub(crate) noise_state: u32,
#[get(type(copy))]
pub(crate) birth_order: u64,
}
#[derive(Clone, Data, Debug)]
pub(crate) struct StereoPcmRingBuffer {
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(skip)]
pub(crate) samples: Vec<f32>,
#[get(type(copy))]
pub(crate) capacity_frames: usize,
#[get(type(copy))]
pub(crate) read_frame: usize,
#[get(type(copy))]
pub(crate) write_frame: usize,
#[get(type(copy))]
pub(crate) buffered_frames: usize,
#[get(type(copy))]
pub(crate) overruns: u64,
#[get(type(copy))]
pub(crate) underruns: u64,
}
#[derive(Data, Debug)]
pub(crate) struct AudioMixerCore {
#[get(type(copy))]
pub(crate) config: AudioOutputConfig,
pub(crate) voices: Vec<AudioSynthVoice>,
pub(crate) ring: StereoPcmRingBuffer,
#[get(type(copy))]
pub(crate) muted: bool,
#[get(type(copy))]
pub(crate) next_birth_order: u64,
#[get(type(copy))]
pub(crate) frames_mixed: u64,
#[get(type(copy))]
pub(crate) commands_ingested: u64,
#[get(type(copy))]
pub(crate) clipped_samples: u64,
#[get(type(copy))]
pub(crate) peak_amplitude: f32,
}
#[cfg(target_os = "macos")]
#[derive(Data, Debug)]
pub(crate) struct CoreAudioAuhalHandle {
#[get(type(copy))]
pub(crate) audio_unit: *mut c_void,
#[get(type(copy))]
pub(crate) callback_context: *mut c_void,
#[get(type(copy))]
pub(crate) running: bool,
}
#[cfg(target_os = "macos")]
#[derive(Data, Default)]
pub(crate) struct NativeAudioDriverSlot {
#[get(skip)]
pub(crate) coreaudio: Option<CoreAudioAuhalHandle>,
}
#[cfg(not(target_os = "macos"))]
#[derive(Data, Default)]
pub(crate) struct NativeAudioDriverSlot {
#[get(type(copy))]
pub(crate) active: bool,
}
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct AudioComponentDescriptionC {
pub(crate) component_type: u32,
pub(crate) component_sub_type: u32,
pub(crate) component_manufacturer: u32,
pub(crate) component_flags: u32,
pub(crate) component_flags_mask: u32,
}
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct AudioStreamBasicDescriptionC {
pub(crate) sample_rate: f64,
pub(crate) format_id: u32,
pub(crate) format_flags: u32,
pub(crate) bytes_per_packet: u32,
pub(crate) frames_per_packet: u32,
pub(crate) bytes_per_frame: u32,
pub(crate) channels_per_frame: u32,
pub(crate) bits_per_channel: u32,
pub(crate) reserved: u32,
}
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct AuRenderCallbackStructC {
pub(crate) input_proc: unsafe extern "C" fn(
*mut c_void,
*mut u32,
*const c_void,
u32,
u32,
*mut AudioBufferListC,
) -> i32,
pub(crate) input_proc_ref_con: *mut c_void,
}
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct AudioBufferC {
pub(crate) number_channels: u32,
pub(crate) data_byte_size: u32,
pub(crate) data: *mut c_void,
}
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct AudioBufferListC {
pub(crate) number_buffers: u32,
pub(crate) buffers: [AudioBufferC; 1],
}
#[derive(Data)]
pub struct AudioOutputBackend {
#[get(type(copy))]
pub(crate) config: AudioOutputConfig,
#[get(pub(crate))]
#[get_mut(skip)]
#[set(skip)]
pub(crate) core: Arc<Mutex<AudioMixerCore>>,
#[get(type(copy))]
pub(crate) driver_kind: AudioDriverKind,
#[get(type(copy))]
pub(crate) state: AudioOutputState,
#[get(pub(crate))]
#[get_mut(pub(crate))]
#[set(skip)]
pub(crate) native_slot: NativeAudioDriverSlot,
}