Skip to content

Commit

Permalink
DEBUG11
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehrsons committed Nov 3, 2023
1 parent 2140238 commit 8df7044
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/backend/device_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
);
Expand Down Expand Up @@ -307,6 +312,20 @@ pub fn get_device_tap_enabled(id: AudioDeviceID) -> std::result::Result<bool, OS
Ok(enabled != 0)
}

pub fn get_device_is_running(id: AudioDeviceID) -> std::result::Result<bool, OSStatus> {
let address = get_property_address(
Property::DeviceIsRunning,
DeviceType::INPUT | DeviceType::OUTPUT,
);
let mut running: u32 = 0;
let mut size = mem::size_of::<u32>();
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,
Expand Down Expand Up @@ -344,6 +363,7 @@ pub fn get_clock_domain(
pub enum Property {
DeviceBufferFrameSizeRange,
DeviceIsAlive,
DeviceIsRunning,
DeviceLatency,
DeviceManufacturer,
DeviceName,
Expand All @@ -370,6 +390,7 @@ impl From<Property> for AudioObjectPropertySelector {
match p {
Property::DeviceBufferFrameSizeRange => kAudioDevicePropertyBufferFrameSizeRange,
Property::DeviceIsAlive => kAudioDevicePropertyDeviceIsAlive,
Property::DeviceIsRunning => kAudioDevicePropertyDeviceIsRunning,
Property::DeviceLatency => kAudioDevicePropertyLatency,
Property::DeviceManufacturer => kAudioObjectPropertyManufacturer,
Property::DeviceName => kAudioObjectPropertyName,
Expand Down

0 comments on commit 8df7044

Please sign in to comment.