Added WASAPI support for SDL_HINT_AUDIO_DEVICE_STREAM_ROLE
Also added SDL_HINT_AUDIO_DEVICE_RAW_STREAM Fixes https://github.com/libsdl-org/SDL/issues/14091
This commit is contained in:
@@ -54,6 +54,9 @@ static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NUL
|
||||
static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2 } };
|
||||
static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } };
|
||||
static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } };
|
||||
#ifdef __IAudioClient2_INTERFACE_DEFINED__
|
||||
static const IID SDL_IID_IAudioClient2 = { 0x726778cd, 0xf60a, 0x4EDA, { 0x82, 0xde, 0xe4, 0x76, 0x10, 0xcd, 0x78, 0xaa } };
|
||||
#endif //
|
||||
#ifdef __IAudioClient3_INTERFACE_DEFINED__
|
||||
static const IID SDL_IID_IAudioClient3 = { 0x7ed4ee07, 0x8e67, 0x4cd4, { 0x8c, 0x1a, 0x2b, 0x7a, 0x59, 0x87, 0xad, 0x42 } };
|
||||
#endif //
|
||||
@@ -727,6 +730,44 @@ static bool mgmtthrtask_PrepDevice(void *userdata)
|
||||
int new_sample_frames = 0;
|
||||
bool iaudioclient3_initialized = false;
|
||||
|
||||
#ifdef __IAudioClient2_INTERFACE_DEFINED__
|
||||
IAudioClient2 *client2 = NULL;
|
||||
ret = IAudioClient_QueryInterface(client, &SDL_IID_IAudioClient2, (void **)&client2);
|
||||
if (SUCCEEDED(ret)) {
|
||||
AudioClientProperties audioProps;
|
||||
|
||||
SDL_zero(audioProps);
|
||||
audioProps.cbSize = sizeof(audioProps);
|
||||
|
||||
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE);
|
||||
if (hint && *hint) {
|
||||
if (SDL_strcasecmp(hint, "Communications") == 0) {
|
||||
audioProps.eCategory = AudioCategory_Communications;
|
||||
} else if (SDL_strcasecmp(hint, "Game") == 0) {
|
||||
// We'll add support for GameEffects as distinct from GameMedia later when we add stream roles
|
||||
audioProps.eCategory = AudioCategory_GameEffects;
|
||||
} else if (SDL_strcasecmp(hint, "GameChat") == 0) {
|
||||
audioProps.eCategory = AudioCategory_GameChat;
|
||||
} else if (SDL_strcasecmp(hint, "Movie") == 0) {
|
||||
audioProps.eCategory = AudioCategory_Movie;
|
||||
} else if (SDL_strcasecmp(hint, "Media") == 0) {
|
||||
audioProps.eCategory = AudioCategory_Media;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_AUDIO_DEVICE_RAW_STREAM, false)) {
|
||||
audioProps.Options = AUDCLNT_STREAMOPTIONS_RAW;
|
||||
}
|
||||
|
||||
ret = IAudioClient2_SetClientProperties(client2, &audioProps);
|
||||
if (FAILED(ret)) {
|
||||
// This isn't fatal, let's log it instead of failing
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_AUDIO, "IAudioClient2_SetClientProperties failed: 0x%lx", ret);
|
||||
}
|
||||
IAudioClient2_Release(client2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __IAudioClient3_INTERFACE_DEFINED__
|
||||
// Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED
|
||||
if (sharemode == AUDCLNT_SHAREMODE_SHARED) {
|
||||
|
||||
Reference in New Issue
Block a user