| 236 | static void ReleaseWasapiDevice(_THIS); |
| 237 | |
| 238 | static SDL_bool |
| 239 | RecoverWasapiDevice(_THIS) |
| 240 | { |
| 241 | ReleaseWasapiDevice(this); /* dump the lost device's handles. */ |
| 242 | |
| 243 | if (this->hidden->default_device_generation) { |
| 244 | this->hidden->default_device_generation = SDL_AtomicGet(this->iscapture ? &WASAPI_DefaultCaptureGeneration : &WASAPI_DefaultPlaybackGeneration); |
| 245 | } |
| 246 | |
| 247 | /* this can fail for lots of reasons, but the most likely is we had a |
| 248 | non-default device that was disconnected, so we can't recover. Default |
| 249 | devices try to reinitialize whatever the new default is, so it's more |
| 250 | likely to carry on here, but this handles a non-default device that |
| 251 | simply had its format changed in the Windows Control Panel. */ |
| 252 | if (WASAPI_ActivateDevice(this, SDL_TRUE) == -1) { |
| 253 | SDL_OpenedAudioDeviceDisconnected(this); |
| 254 | return SDL_FALSE; |
| 255 | } |
| 256 | |
| 257 | this->hidden->device_lost = SDL_FALSE; |
| 258 | |
| 259 | return SDL_TRUE; /* okay, carry on with new device details! */ |
| 260 | } |
| 261 | |
| 262 | static SDL_bool |
| 263 | RecoverWasapiIfLost(_THIS) |
no test coverage detected