| 314 | } |
| 315 | |
| 316 | int |
| 317 | WASAPI_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 | |
| 354 | typedef struct |
no test coverage detected