Thread Safety - MaulingMonkey/thindx-xaudio2 GitHub Wiki
...XAudio2 might be beholden to the monster that is COM's threading model.
XAudio 2.7
CLSID_XAudio2→HKEY_CLASSES_ROOT\CLSID\{5a508685-a254-4fba-9b82-9a24b00306af}\InProcServer32\ThreadingModel = Both- Resulting COM objects can only be accessed from within the same apartment (means we can't
SendfromMTA→STA) - If we can forcibly create the class in the neutral apartment, that might suffice to make things
Sendable?
- Resulting COM objects can only be accessed from within the same apartment (means we can't
XAudio 2.9
- No CLSID, and creation can succeed without COM being initialized (although doing much still requires COM init)
- It's possible to create and use IXAudio2 s from both single threaded and multi-threaded apartments
- No thread safety hinting interfaces are implemented (e.g.
IAgileObject,IMarshal,INoMarshal, ...)
References
The Old New Thing:
- Neutral Apartments (microsoft.com)
- Threading Model Attribute (microsoft.com)
- How do I get a foothold in the neutral apartment? (The Old New Thing)
- How do you get into a context via
IContextCallback::ContextCallback? (The Old New Thing) - Understanding and Using COM Threading Models (microsoft.com)
- Processes, Threads, and Apartments (microsoft.com)
Agile objects in C++/WinRT(microsoft.com)- Understanding The COM Single-Threaded Apartment Part 1 (codeproject.com)
- Single-Threaded Apartments (microsoft.com) ≈
!Send + !Sync - Multithreaded Apartments (microsoft.com) ≈
Send + Sync, but only within MTA threads (e.g. can't send MTA objects to STA threads nor call their methods.)