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

Function WASAPI_ActivateDevice

deps/SDL2/src/audio/wasapi/SDL_wasapi_win32.c:316–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316int
317WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery)
318{
319 LPCWSTR devid = this->hidden->devid;
320 IMMDevice *device = NULL;
321 HRESULT ret;
322
323 if (devid == NULL) {
324 const EDataFlow dataflow = this->iscapture ? eCapture : eRender;
325 ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_WASAPI_role, &device);
326 } else {
327 ret = IMMDeviceEnumerator_GetDevice(enumerator, devid, &device);
328 }
329
330 if (FAILED(ret)) {
331 SDL_assert(device == NULL);
332 this->hidden->client = NULL;
333 return WIN_SetErrorFromHRESULT("WASAPI can't find requested audio endpoint", ret);
334 }
335
336 /* this is not async in standard win32, yay! */
337 ret = IMMDevice_Activate(device, &SDL_IID_IAudioClient, CLSCTX_ALL, NULL, (void **) &this->hidden->client);
338 IMMDevice_Release(device);
339
340 if (FAILED(ret)) {
341 SDL_assert(this->hidden->client == NULL);
342 return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret);
343 }
344
345 SDL_assert(this->hidden->client != NULL);
346 if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */
347 return -1;
348 }
349
350 return 0; /* good to go. */
351}
352
353
354typedef struct

Callers 2

RecoverWasapiDeviceFunction · 0.70
WASAPI_OpenDeviceFunction · 0.70

Calls 2

WIN_SetErrorFromHRESULTFunction · 0.85
WASAPI_PrepDeviceFunction · 0.85

Tested by

no test coverage detected