-
Notifications
You must be signed in to change notification settings - Fork 0
Thread Safety
MaulingMonkey edited this page Feb 18, 2024
·
1 revision
...XAudio2 might be beholden to the monster that is COM's threading model.
-
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
Send
fromMTA
→STA
) - If we can forcibly create the class in the neutral apartment, that might suffice to make things
Send
able?
- Resulting COM objects can only be accessed from within the same apartment (means we can't
- 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
, ...)
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.)