Closed lukors closed 3 years ago
COM initialization is per thread, so shouldn't it be possible to start a seperate thread for CPAL that uses multithreaded COM?
It might also be possible for cpal to just use a more compatible mode to begin with. Someone needs to put in the effort to research the Windows APIs in question and determine the proper solution; maybe look at what portaudio and SDL do about this problem.
I'm the author of rfd, and I'm also struggling with this issue, I'm not knowable enough in Windows API to propose any solutions, but I think the community should join forces together and solve this once for all, the issue affects rfd
,cpal
,winit
,bevy
, and probably many more consumers of win COM API
I haven't really used this library, but shouldn't COM initialization be single-threaded? #59
I should preface this with that I don't really know what I'm talking about here, I'm just trying to solve an issue that I'm running into in the Bevy game engine, so I'm looking around to try finding possible solutions. So please correct me if I'm wrong anywhere. :)
In Bevy there are some issues with COM and it being single-threaded or multi-threaded. Drag and drop in Bevy uses single-threaded COM (I think it needs to?), and cpal uses multi-threaded. This causes issues because it seems like COM can only be initialized as single-threaded or multi-threaded for each thread, otherwise it crashes.
I don't know if or how this can be solved in Bevy, but one gracious Bevy community member says it worked for them when they modified the cpal source so it initializes in single threaded mode.
My question is: would it make sense as a feature in cpal to enable the ability to initialize it in single threaded mode if the user wants?
Here's one of the places where we've talked about this: https://github.com/bevyengine/bevy/issues/2096