We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4224 - [Patch] [WinRT] Call PrepDevice during SDL_OpenAudioDevice, not on the audio thread
Summary: [Patch] [WinRT] Call PrepDevice during SDL_OpenAudioDevice, not on the audio ...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: HG 2.0
Hardware: All Windows 10
: P2 major
Assignee: Ethan Lee
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-09 14:48 UTC by Ethan Lee
Modified: 2018-09-26 02:50 UTC (History)
0 users

See Also:


Attachments
Patch to fix WASAPI device init for WinRT (2.44 KB, text/plain)
2018-08-09 14:48 UTC, Ethan Lee
Details
Patch to fix WASAPI device init for WinRT [v2] (2.45 KB, patch)
2018-09-17 19:24 UTC, Ethan Lee
Details | Diff
Patch to fix WASAPI device init for WinRT [v3] (4.41 KB, patch)
2018-09-25 05:46 UTC, Ethan Lee
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ethan Lee 2018-08-09 14:48:32 UTC
Created attachment 3277 [details]
Patch to fix WASAPI device init for WinRT

Attached is a patch that fixes a whole bunch of WASAPI WinRT bugs at once. All it does is move PrepDevice away from the thread and into the ActivateDevice routine, waiting until the async call is complete to do so. It's not the most pleasant thing in the world but the bugs that happen if we _don't_ do this are significantly worse.
Comment 1 Ethan Lee 2018-09-17 19:24:01 UTC
Created attachment 3305 [details]
Patch to fix WASAPI device init for WinRT [v2]

Patch has been updated to use the 'isrecovery' parameter from WASAPI_ActivateDevice. This is necessary for supporting multichannel audio when the requested channel count does not match the device's native channel count.
Comment 2 Sam Lantinga 2018-09-24 23:47:21 UTC
This code will spin forever if ActivateCompleted() fails. Can you update the patch to handle that case?
Comment 3 Ethan Lee 2018-09-25 05:46:06 UTC
Created attachment 3311 [details]
Patch to fix WASAPI device init for WinRT [v3]

Patch has been updated to do all of the ActivateResult work on the main thread. This should prevent infinite spinning and is probably safer in other ways as well. Tested on Xbone and Windows 10.
Comment 4 Sam Lantinga 2018-09-26 02:50:05 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/09e314140a28