directsound: First shot at updating for SDL3 audio API.

This does an enormous amount of work in SDL_immdevice.c to simplify and
clean up that interface, while moving some of its responsibilities to the
higher level SDL_audio.c. I hope I saw the whole picture here, and this
wasn't foolhardy of me.

WASAPI has not been updated for these changes, or for SDL3 at all, yet. As
such, it continues to be broken for now. It will be updated soon.

This code compiles with my cross compiler, but hasn't been built with
Visual Studio, or tested in any form, so there might be obvious fixes
following along shortly.
This commit is contained in:
Ryan C. Gordon 2023-07-11 17:32:31 -04:00
parent 4399b71715
commit 77b3fb06ee
No known key found for this signature in database
GPG key ID: FA148B892AB48044
5 changed files with 369 additions and 458 deletions

View file

@ -26,16 +26,15 @@
#include <mmdeviceapi.h>
#include <mmreg.h>
typedef struct SDL_AudioDevice SDL_AudioDevice; // this is defined in src/audio/SDL_sysaudio.h
int SDL_IMMDevice_Init(void);
void SDL_IMMDevice_Quit(void);
int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture);
void SDL_IMMDevice_EnumerateEndpoints(SDL_bool useguid);
int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture);
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool iscapture);
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture);
LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);
void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device);
SDL_AudioFormat WaveFormatToSDLFormat(WAVEFORMATEX *waveformat);
/* these increment as default devices change. Opened default devices pick up changes in their threads. */
extern SDL_AtomicInt SDL_IMMDevice_DefaultPlaybackGeneration;
extern SDL_AtomicInt SDL_IMMDevice_DefaultCaptureGeneration;
#endif /* SDL_IMMDEVICE_H */