1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 */ 21 #include "../../SDL_internal.h" 22 23 #ifndef SDL_wasapi_h_ 24 #define SDL_wasapi_h_ 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #include "../SDL_sysaudio.h" 31 32 /* Hidden "this" pointer for the audio functions */ 33 #ifdef __cplusplus 34 #define _THIS SDL_AudioDevice *_this 35 #else 36 #define _THIS SDL_AudioDevice *this 37 #endif 38 39 struct SDL_PrivateAudioData 40 { 41 SDL_atomic_t refcount; 42 WCHAR *devid; 43 WAVEFORMATEX *waveformat; 44 IAudioClient *client; 45 IAudioRenderClient *render; 46 IAudioCaptureClient *capture; 47 SDL_AudioStream *capturestream; 48 HANDLE event; 49 HANDLE task; 50 SDL_bool coinitialized; 51 int framesize; 52 int default_device_generation; 53 SDL_bool device_lost; 54 void *activation_handler; 55 SDL_atomic_t just_activated; 56 }; 57 58 /* these increment as default devices change. Opened default devices pick up changes in their threads. */ 59 extern SDL_atomic_t WASAPI_DefaultPlaybackGeneration; 60 extern SDL_atomic_t WASAPI_DefaultCaptureGeneration; 61 62 /* win32 and winrt implementations call into these. */ 63 int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream); 64 void WASAPI_RefDevice(_THIS); 65 void WASAPI_UnrefDevice(_THIS); 66 void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid); 67 void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid); 68 69 /* These are functions that are implemented differently for Windows vs WinRT. */ 70 int WASAPI_PlatformInit(void); 71 void WASAPI_PlatformDeinit(void); 72 void WASAPI_EnumerateEndpoints(void); 73 int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery); 74 void WASAPI_PlatformThreadInit(_THIS); 75 void WASAPI_PlatformThreadDeinit(_THIS); 76 void WASAPI_PlatformDeleteActivationHandler(void *handler); 77 void WASAPI_BeginLoopIteration(_THIS); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif /* SDL_wasapi_h_ */ 84 85 /* vi: set ts=4 sw=4 expandtab: */ 86