MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / WASAPI_OpenDevice

Function WASAPI_OpenDevice

deps/SDL2/src/audio/wasapi/SDL_wasapi.c:662–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660
661
662static int
663WASAPI_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
664{
665 LPCWSTR devid = (LPCWSTR) handle;
666
667 /* Initialize all variables that we clean on shutdown */
668 this->hidden = (struct SDL_PrivateAudioData *)
669 SDL_malloc((sizeof *this->hidden));
670 if (this->hidden == NULL) {
671 return SDL_OutOfMemory();
672 }
673 SDL_zerop(this->hidden);
674
675 WASAPI_RefDevice(this); /* so CloseDevice() will unref to zero. */
676
677 if (!devid) { /* is default device? */
678 this->hidden->default_device_generation = SDL_AtomicGet(iscapture ? &WASAPI_DefaultCaptureGeneration : &WASAPI_DefaultPlaybackGeneration);
679 } else {
680 this->hidden->devid = WStrDupe(devid);
681 if (!this->hidden->devid) {
682 return SDL_OutOfMemory();
683 }
684 }
685
686 if (WASAPI_ActivateDevice(this, SDL_FALSE) == -1) {
687 return -1; /* already set error. */
688 }
689
690 /* Ready, but waiting for async device activation.
691 Until activation is successful, we will report silence from capture
692 devices and ignore data on playback devices.
693 Also, since we don't know the _actual_ device format until after
694 activation, we let the app have whatever it asks for. We set up
695 an SDL_AudioStream to convert, if necessary, once the activation
696 completes. */
697
698 return 0;
699}
700
701static void
702WASAPI_ThreadInit(_THIS)

Callers

nothing calls this directly

Calls 5

SDL_mallocFunction · 0.85
WASAPI_RefDeviceFunction · 0.85
SDL_AtomicGetFunction · 0.85
WStrDupeFunction · 0.85
WASAPI_ActivateDeviceFunction · 0.70

Tested by

no test coverage detected