diff --git a/src/backend/device_property.rs b/src/backend/device_property.rs index 4aa9d870..c58a8179 100644 --- a/src/backend/device_property.rs +++ b/src/backend/device_property.rs @@ -267,7 +267,7 @@ pub fn get_device_stream_configuration( let mut buffers = unsafe { slice::from_raw_parts(ptr, len) }; cubeb_log!( - "get_device_stream_configuration id={}; type={}; tap {}; num_buffers={}, buffers={:?}", + "get_device_stream_configuration id={}; type={}; tap {}; running={}; num_buffers={}, buffers={:?}", id, match devtype { DeviceType::INPUT => "INPUT", @@ -279,6 +279,11 @@ pub fn get_device_stream_configuration( Ok(false) => "not enabled", _ => "ERRORED", }, + match get_device_is_running(id) { + Ok(true) => "true", + Ok(false) => "false", + _ => "ERRORED", + }, len, buffers ); @@ -307,6 +312,20 @@ pub fn get_device_tap_enabled(id: AudioDeviceID) -> std::result::Result std::result::Result { + let address = get_property_address( + Property::DeviceIsRunning, + DeviceType::INPUT | DeviceType::OUTPUT, + ); + let mut running: u32 = 0; + let mut size = mem::size_of::(); + let err = audio_object_get_property_data(id, &address, &mut size, &mut running); + if err != NO_ERR { + return Err(err); + } + Ok(running != 0) +} + pub fn get_stream_latency( id: AudioStreamID, devtype: DeviceType, @@ -344,6 +363,7 @@ pub fn get_clock_domain( pub enum Property { DeviceBufferFrameSizeRange, DeviceIsAlive, + DeviceIsRunning, DeviceLatency, DeviceManufacturer, DeviceName, @@ -370,6 +390,7 @@ impl From for AudioObjectPropertySelector { match p { Property::DeviceBufferFrameSizeRange => kAudioDevicePropertyBufferFrameSizeRange, Property::DeviceIsAlive => kAudioDevicePropertyDeviceIsAlive, + Property::DeviceIsRunning => kAudioDevicePropertyDeviceIsRunning, Property::DeviceLatency => kAudioDevicePropertyLatency, Property::DeviceManufacturer => kAudioObjectPropertyManufacturer, Property::DeviceName => kAudioObjectPropertyName,