getDefaultAudioEndpoint method
Retrieves the default audio endpoint for the specified data-flow direction and role.
Throws a WindowsException on failure.
To learn more, see learn.microsoft.com/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdeviceenumerator-getdefaultaudioendpoint.
Implementation
IMMDevice? getDefaultAudioEndpoint(EDataFlow dataFlow, ERole role) {
final ppEndpoint = adaptiveCalloc<VTablePointer>();
final hr$ = HRESULT(
_GetDefaultAudioEndpointFn(ptr, dataFlow, role, ppEndpoint),
);
if (hr$.isError) {
free(ppEndpoint);
throw WindowsException(hr$);
}
final result$ = ppEndpoint.value;
free(ppEndpoint);
if (result$.isNull) return null;
return .new(result$);
}