wasapi: Deal with device failures when we aren't holding the device lock.

Since these get proxied to a different thread, if we wait for that thread
to finish while holding the lock, and the management thread _also_ requests
the lock, we're screwed.

WaitDevice never holds the lock by design, so just mark devices as failed
and clean up or recover them in there.
This commit is contained in:
Ryan C. Gordon
2023-09-27 11:33:51 -04:00
parent ea5f59c234
commit 505dc4c39c
3 changed files with 28 additions and 15 deletions

View File

@@ -41,12 +41,13 @@ struct SDL_PrivateAudioData
SDL_bool coinitialized;
int framesize;
SDL_bool device_lost;
SDL_bool device_dead;
void *activation_handler;
};
/* win32 and winrt implementations call into these. */
int WASAPI_PrepDevice(SDL_AudioDevice *device);
void WASAPI_DisconnectDevice(SDL_AudioDevice *device);
void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device lock when calling this!
// BE CAREFUL: if you are holding the device lock and proxy to the management thread with wait_until_complete, and grab the lock again, you will deadlock.