Skip to content

Add get_device_format method to Device - #49

Merged
HEnquist merged 4 commits into
HEnquist:masterfrom
edvard-pettersen-elas-ai:user/edvardsp/device-format-property
Sep 6, 2025
Merged

HEnquist merged 4 commits into
HEnquist:masterfrom
edvard-pettersen-elas-ai:user/edvardsp/device-format-property

Conversation

@edvard-pettersen-elas-ai

@edvard-pettersen-elas-ai edvard-pettersen-elas-ai commented Aug 29, 2025 •

Copy link
Copy Markdown

The get_device_format method retrieves the device format from the PKEY_AudioEngine_DeviceFormat device property, which is based on the WAVEFORMATEX structure.

@edvard-pettersen-elas-ai

Copy link
Copy Markdown
Author

Note that I cannot use WaveFormat::from_waveformatex as-is since it takes ownership of the WAVEFORMATEX value rather than borrowing it. As a result, I cannot pass a WAVEFORMATEX that is actually a WAVEFORMATEXTENSIBLE in memory, since the additional fields beyond the base struct would be truncated and lost.

@HEnquist

Copy link
Copy Markdown
Owner

Looks great at a glance, thanks! I'll look closely as soon as I have a little free time.

Comment thread src/api.rs Outdated

/// Read a string property from an [IMMDevice]
fn get_string_property(&self, key: &PROPERTYKEY) -> WasapiRes<String> {
self.get_property(key, |prop| {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these parse functions need to be closures? If possible, I think it gets easier to read if they are normal functions (private of course).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can make them private functions.

@HEnquist
HEnquist merged commit 4852a4c into HEnquist:master Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants