Reenable WasApi loopback

This commit is contained in:
dheijl 2020-09-10 15:32:18 +02:00
parent 3d2fddc13e
commit 78e8452150

View file

@ -33,8 +33,7 @@ use super::winapi::um::audioclient::{
self, IAudioClient, IID_IAudioClient, AUDCLNT_E_DEVICE_INVALIDATED, self, IAudioClient, IID_IAudioClient, AUDCLNT_E_DEVICE_INVALIDATED,
}; };
use super::winapi::um::audiosessiontypes::{ use super::winapi::um::audiosessiontypes::{
AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, AUDCLNT_STREAMFLAGS_LOOPBACK};
};
use super::winapi::um::combaseapi::{ use super::winapi::um::combaseapi::{
CoCreateInstance, CoTaskMemFree, PropVariantClear, CLSCTX_ALL, CoCreateInstance, CoTaskMemFree, PropVariantClear, CLSCTX_ALL,
}; };
@ -657,6 +656,13 @@ impl Device {
BufferSize::Default => (), BufferSize::Default => (),
}; };
let mut stream_flags: DWORD = AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
if self.data_flow() == eRender {
stream_flags |= AUDCLNT_STREAMFLAGS_LOOPBACK;
}
// Computing the format and initializing the device.
// Computing the format and initializing the device. // Computing the format and initializing the device.
let waveformatex = { let waveformatex = {
let format_attempt = config_to_waveformatextensible(config, sample_format) let format_attempt = config_to_waveformatextensible(config, sample_format)
@ -673,7 +679,7 @@ impl Device {
// finally initializing the audio client // finally initializing the audio client
let hresult = (*audio_client).Initialize( let hresult = (*audio_client).Initialize(
share_mode, share_mode,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, stream_flags,
0, 0,
0, 0,
&format_attempt.Format, &format_attempt.Format,