use std::{ffi::c_void, ptr::NonNull};
use crate::{at::audio, define_opts, four_cc_fmt_debug};
#[cfg(feature = "blocks")]
use crate::blocks;
#[doc(alias = "AudioQueuePropertyID")]
#[repr(transparent)]
pub struct QueueProp(pub u32);
#[doc(alias = "AudioQueueParameterID")]
#[repr(transparent)]
pub struct QueueParam(pub u32);
#[doc(alias = "AudioQueueParameterValue")]
pub type QueueParamValue = f32;
#[doc(alias = "AudioQueueRef")]
#[repr(transparent)]
pub struct Queue(NonNull<c_void>);
#[repr(transparent)]
pub struct QueueTimeline(NonNull<c_void>);
pub mod err {
use crate::os::Error;
pub const INVALID_BUFFER: Error = Error::new_unchecked(-66687);
pub const BUFFER_EMPTY: Error = Error::new_unchecked(-66686);
pub const DISPOSAL_PENDING: Error = Error::new_unchecked(-66685);
pub const INVALID_PROPERTY: Error = Error::new_unchecked(-66684);
pub const INVALID_PROPERTY_SIZE: Error = Error::new_unchecked(-66683);
pub const INVALID_PARAMETER: Error = Error::new_unchecked(-66682);
pub const CANNOT_START: Error = Error::new_unchecked(-66681);
pub const INVALID_DEVICE: Error = Error::new_unchecked(-66680);
pub const BUFFER_IN_QUEUE: Error = Error::new_unchecked(-66679);
pub const INVALID_RUN_STATE: Error = Error::new_unchecked(-66678);
pub const INVALID_QUEUE_TYPE: Error = Error::new_unchecked(-66677);
pub const PERMISSIONS: Error = Error::new_unchecked(-66676);
pub const INVALID_PROPERTY_VALUE: Error = Error::new_unchecked(-66675);
pub const PRIME_TIMED_OUT: Error = Error::new_unchecked(-66674);
pub const CODEC_NOT_FOUND: Error = Error::new_unchecked(-66673);
pub const INVALID_CODEC_ACCESS: Error = Error::new_unchecked(-66672);
pub const QUEUE_INVALIDATED: Error = Error::new_unchecked(-66671);
pub const TOO_MANY_TAPS: Error = Error::new_unchecked(-66670);
pub const INVALID_TAP_CONTEXT: Error = Error::new_unchecked(-66669);
pub const RECORD_UNDERRUN: Error = Error::new_unchecked(-66668);
pub const INVALID_TAP_TYPE: Error = Error::new_unchecked(-66667);
pub const BUFFER_ENQUEUED_TWICE: Error = Error::new_unchecked(-66666);
pub const CANNOT_START_YET: Error = Error::new_unchecked(-66665);
pub const ENQUEUE_DURING_RESET: Error = Error::new_unchecked(-66632);
pub const INVALID_OFFLINE_MODE: Error = Error::new_unchecked(-66626);
}
impl QueueProp {
#[doc(alias = "kAudioQueueProperty_IsRunning")]
pub const IS_RUNNING: Self = Self(u32::from_be_bytes(*b"aqrn"));
#[doc(alias = "kAudioQueueDeviceProperty_SampleRate")]
pub const SAMPLE_RATE: Self = Self(u32::from_be_bytes(*b"aqsr"));
#[doc(alias = "kAudioQueueDeviceProperty_NumberChannels")]
pub const NUMBER_CHANNELS: Self = Self(u32::from_be_bytes(*b"aqdc"));
#[doc(alias = "kAudioQueueProperty_CurrentDevice")]
pub const CURRENT_DEVICE: Self = Self(u32::from_be_bytes(*b"aqcd"));
#[doc(alias = "kAudioQueueProperty_MagicCookie")]
pub const MAGIC_COOKIE: Self = Self(u32::from_be_bytes(*b"aqmc"));
#[doc(alias = "kAudioQueueProperty_MaximumOutputPacketSize")]
pub const MAX_OUTPUT_PACKET_SIZE: Self = Self(u32::from_be_bytes(*b"xops"));
#[doc(alias = "kAudioQueueProperty_StreamDescription")]
pub const STREAM_DESCRIPTION: Self = Self(u32::from_be_bytes(*b"aqft"));
#[doc(alias = "kAudioQueueProperty_ChannelLayout")]
pub const CHANNEL_LAYOUT: Self = Self(u32::from_be_bytes(*b"aqcl"));
#[doc(alias = "kAudioQueueProperty_EnableLevelMetering")]
pub const ENABLE_LEVEL_METERING: Self = Self(u32::from_be_bytes(*b"aqme"));
#[doc(alias = "kAudioQueueProperty_CurrentLevelMeter")]
pub const CURRENT_LEVEL_METER: Self = Self(u32::from_be_bytes(*b"aqmv"));
#[doc(alias = "kAudioQueueProperty_CurrentLevelMeterDB")]
pub const CURRENT_LEVEL_METER_DB: Self = Self(u32::from_be_bytes(*b"aqmd"));
#[doc(alias = "kAudioQueueProperty_DecodeBufferSizeFrames")]
pub const DECODE_BUFFER_SIZE_FRAMES: Self = Self(u32::from_be_bytes(*b"dcbf"));
#[doc(alias = "kAudioQueueProperty_ConverterError")]
pub const CONVERTER_ERROR: Self = Self(u32::from_be_bytes(*b"qcve"));
#[doc(alias = "kAudioQueueProperty_EnableTimePitch")]
pub const ENABLE_TIME_PITCH: Self = Self(u32::from_be_bytes(*b"q_tp"));
#[doc(alias = "kAudioQueueProperty_TimePitchAlgorithm")]
pub const TIME_PITCH_ALGORITHM: Self = Self(u32::from_be_bytes(*b"qtpa"));
#[doc(alias = "kAudioQueueProperty_TimePitchBypass")]
pub const TIME_PITCH_BYPASS: Self = Self(u32::from_be_bytes(*b"qtpb"));
}
#[doc(alias = "AudioQueueTimePitchAlgorithm")]
#[repr(transparent)]
pub struct QueueTimePitchAlgorithm(pub u32);
impl QueueTimePitchAlgorithm {
#[doc(alias = "kAudioQueueTimePitchAlgorithm_Spectral")]
pub const SPECTRAL: Self = Self(u32::from_be_bytes(*b"spec"));
#[doc(alias = "kAudioQueueTimePitchAlgorithm_TimeDomain")]
pub const TIME_DOMAIN: Self = Self(u32::from_be_bytes(*b"tido"));
#[doc(alias = "kAudioQueueTimePitchAlgorithm_Varispeed")]
pub const VARISPEED: Self = Self(u32::from_be_bytes(*b"vspd"));
}
impl std::fmt::Debug for QueueTimePitchAlgorithm {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
four_cc_fmt_debug(self.0, "QueueTimePitchAlgorithm", f)
}
}
impl QueueProp {
#[doc(alias = "kAudioQueueProperty_HardwareCodecPolicy")]
pub const HARDWARE_CODEC_POLICY: Self = Self(u32::from_be_bytes(*b"aqcp"));
#[doc(alias = "kAudioQueueProperty_ChannelAssignments")]
pub const CHANNEL_ASSIGNMENTS: Self = Self(u32::from_be_bytes(*b"aqca"));
}
impl std::fmt::Debug for QueueProp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
four_cc_fmt_debug(self.0, "QueueProp", f)
}
}
impl QueueParam {
#[doc(alias = "kAudioQueueParam_Volume")]
pub const VOLUME: Self = Self(1);
#[doc(alias = "kAudioQueueParam_PlayRate")]
pub const PLAY_RATE: Self = Self(2);
#[doc(alias = "kAudioQueueParam_Pitch")]
pub const PITCH: Self = Self(3);
#[doc(alias = "kAudioQueueParam_VolumeRampTime")]
pub const VOLUME_RAMP_TIME: Self = Self(4);
#[doc(alias = "kAudioQueueParam_Pan")]
pub const PAN: Self = Self(4);
}
define_opts!(
#[doc(alias = "AudioQueueProcessingTapFlags")]
pub QueueProcessingTapFlags(u32)
);
impl QueueProcessingTapFlags {
#[doc(alias = "kAudioQueueProcessingTap_PreEffects")]
pub const PRE_EFFECTS: Self = Self(1 << 0);
#[doc(alias = "kAudioQueueProcessingTap_PostEffects")]
pub const POST_EFFECTS: Self = Self(1 << 1);
#[doc(alias = "kAudioQueueProcessingTap_StartOfStream")]
pub const START_OF_STREAM: Self = Self(1 << 8);
#[doc(alias = "kAudioQueueProcessingTap_EndOfStream")]
pub const END_OF_STREAM: Self = Self(1 << 9);
}
#[doc(alias = "AudioQueueBuffer")]
#[repr(C)]
pub struct QueueBuf {
pub audio_data_bytes_capacity: u32,
pub audio_data: *const c_void,
pub audio_data_byte_size: u32,
pub user_data: *mut c_void,
pub packet_description_capacity: u32,
pub packet_descriptions: *const audio::StreamPacketDesc,
pub packet_description_count: u32,
}
#[doc(alias = "AudioQueueParameterEvent")]
#[repr(C)]
pub struct QueueParamEvent {
pub id: QueueParam,
pub value: QueueParamValue,
}
#[doc(alias = "AudioQueueLevelMeterState")]
#[repr(C)]
pub struct QueueLevelMeterState {
pub average_power: f32,
pub peak_power: f32,
}
#[doc(alias = "AudioQueueOutputCallbackBlock")]
#[cfg(feature = "blocks")]
pub type QueueOutputCbBlock = blocks::EscBlock<fn(&mut Queue, &mut QueueBuf)>;
#[doc(alias = "AudioQueueInputCallbackBlock")]
#[cfg(feature = "blocks")]
pub type QueueInputCbBlock = blocks::EscBlock<
fn(&mut Queue, &mut QueueBuf, *const audio::TimeStamp, u32, *const audio::StreamPacketDesc),
>;
#[doc(alias = "AudioQueueOutputCallback")]
pub type QueueOutputCb = extern "C" fn(*mut c_void, &mut Queue, &mut QueueBuf);
#[doc(alias = "AudioQueueInputCallback")]
pub type QueueInputCb = extern "C" fn(
*mut c_void,
&mut Queue,
&mut QueueBuf,
*const audio::TimeStamp,
u32,
*const audio::StreamPacketDesc,
);
#[doc(alias = "AudioQueuePropertyListenerProc")]
pub type QueuePropListenerProc = extern "C" fn(*mut c_void, &mut Queue, QueueProp);