diff --git a/cidre/src/core_audio/hardware.rs b/cidre/src/core_audio/hardware.rs index b1d9830f..0c6377c2 100644 --- a/cidre/src/core_audio/hardware.rs +++ b/cidre/src/core_audio/hardware.rs @@ -369,9 +369,16 @@ impl System { } #[doc(alias = "kAudioHardwarePropertyClockDeviceList")] - pub fn clock_device_list() -> os::Result> { + pub fn clocks() -> os::Result> { Self::OBJ.prop_vec(&PropSelector::HARDWARE_CLOCK_DEVICE_LIST.global_addr()) } + + /// An array of AudioObjectIds that represent the Process objects for all client processes + /// currently connected to the system. + #[doc(alias = "kAudioHardwarePropertyProcessObjectList")] + pub fn processes() -> os::Result> { + Self::OBJ.prop_vec(&PropSelector::HARDWARE_PROCESS_OBJ_LIST.global_addr()) + } } /// AudioSystemObject Properties @@ -424,6 +431,10 @@ impl PropSelector { /// currently provided by the system. #[doc(alias = "kAudioHardwarePropertyClockDeviceList")] pub const HARDWARE_CLOCK_DEVICE_LIST: Self = Self(u32::from_be_bytes(*b"clk#")); + + /// An array of AudioObjectIDs that represent the Tap objects on the system. + #[doc(alias = "kAudioHardwarePropertyTapList")] + pub const HARDWARE_TAP_LIST: Self = Self(u32::from_be_bytes(*b"tps#")); } /// AudioAggregateDevice Properties @@ -548,6 +559,42 @@ impl Device { self.prop(&PropSelector::DEVICE_TRANSPORT_TYPE.global_addr()) } + /// A f64 that indicates the current actual sample rate of the AudioDevice + /// as measured by its time stamps. + #[doc(alias = "kAudioDevicePropertyActualSampleRate")] + pub fn actual_sample_rate(&self) -> os::Result { + self.prop(&PropSelector::DEVICE_ACTUAL_SAMPLE_RATE.global_addr()) + } + + /// A cf::String that contains the UID for the AudioClockDevice that is currently + /// serving as the main time base of the device. + #[doc(alias = "kAudioDevicePropertyClockDevice")] + pub fn clock_uid(&self) -> os::Result> { + self.cf_prop(&PropSelector::DEVICE_CLOCK_DEVICE.global_addr()) + } + + /// Indicates that the current process's audio will be zeroed out by the system. + /// + /// Note that this property does not apply to aggregate devices, just real, physical devices. + #[doc(alias = "kAudioDevicePropertyProcessMute")] + pub fn is_process_muted(&self, scope: PropScope) -> os::Result { + let addr = PropAddr { + selector: PropSelector::DEVICE_PROCESS_MUTE, + scope, + element: PropElement::WILDCARD, + }; + + self.bool_prop(&addr) + } + + pub fn is_process_input_muted(&self) -> os::Result { + self.is_process_muted(PropScope::INPUT) + } + + pub fn is_process_output_muted(&self) -> os::Result { + self.is_process_muted(PropScope::OUTPUT) + } + #[doc(alias = "AudioDeviceCreateIOProcID")] pub fn create_io_proc_id( &self, @@ -1777,7 +1824,7 @@ mod tests { #[test] fn clock() { - let clocks = System::clock_device_list().unwrap(); + let clocks = System::clocks().unwrap(); for c in clocks { assert_eq!(Class::CLOCK, c.class().unwrap()); assert_eq!(Class::OBJECT, c.base_class().unwrap()); diff --git a/cidre/src/core_audio/hardware_tapping.rs b/cidre/src/core_audio/hardware_tapping.rs index ac182a14..522f0c3c 100644 --- a/cidre/src/core_audio/hardware_tapping.rs +++ b/cidre/src/core_audio/hardware_tapping.rs @@ -18,6 +18,12 @@ impl std::ops::Deref for TapGuard { } } +impl std::ops::DerefMut for TapGuard { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + impl Drop for TapGuard { fn drop(&mut self) { let res = unsafe { AudioHardwareDestroyProcessTap(self.0 .0) }; @@ -48,6 +54,10 @@ impl Tap { self.cf_prop(&PropSelector::TAP_DESCRIPTION.global_addr()) } + pub fn set_desc(&mut self, val: arc::R) -> os::Result { + self.set_prop(&PropSelector::TAP_DESCRIPTION.global_addr(), &val) + } + /// An cat::AudioStreamBasicDesc that describes the current data format for /// the tap. This is the format of that data that will be accessible in any aggregate /// device that contains the tap. @@ -82,7 +92,8 @@ pub mod tests { let desc = { let tap_desc = TapDesc::with_stereo_global_tap_excluding_processes(&ns::Array::new()); println!("{tap_desc:?}"); - let tap = tap_desc.create_process_tap().unwrap(); + let mut tap = tap_desc.create_process_tap().unwrap(); + tap.set_desc(tap_desc).unwrap(); let uid = tap.uid().unwrap(); println!("{uid:?}"); let asbd = tap.asbd();