Don't try using the DirectSound backend if not all APIs are available.

This affects Windows 95. It does not appear to have at least one of
these functions. This is convenient because the function
IDirectSound::CreateSoundBuffer() is failing in my tests and I wasn't
able to figure out what was going on. Simply failing context
initialization outright is an acceptable solution for now since
Windows 95 is such an uncommon target and it can always fall back to
WinMM which works.
This commit is contained in:
David Reid
2023-01-03 19:10:14 +10:00
parent fcdd14cd61
commit 78897b3e95
+12
View File
@@ -25010,6 +25010,18 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_
pContext->dsound.DirectSoundCaptureCreate = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureCreate");
pContext->dsound.DirectSoundCaptureEnumerateA = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureEnumerateA");
/*
We need to support all functions or nothing. DirectSound with Windows 95 seems to not work too
well in my testing. For example, it's missing DirectSoundCaptureEnumerateA(). This is a convenient
place to just disable the DirectSound backend for Windows 95.
*/
if (pContext->dsound.DirectSoundCreate == NULL ||
pContext->dsound.DirectSoundEnumerateA == NULL ||
pContext->dsound.DirectSoundCaptureCreate == NULL ||
pContext->dsound.DirectSoundCaptureEnumerateA == NULL) {
return MA_API_NOT_FOUND;
}
pCallbacks->onContextInit = ma_context_init__dsound;
pCallbacks->onContextUninit = ma_context_uninit__dsound;
pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;