You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note In Windows 8, the first use of IAudioClient to access the audio device should be on the STA thread. Calls from an MTA thread may result in undefined behavior.
cpal initializes COM in MTA mode.
The text was updated successfully, but these errors were encountered:
COM can prevent undefined behavior in either concurrency model by
performing marshaling when necessary. As a result, CoInitializeEx can be
called with either concurrency model, and in this case STA provides better
compatibility with other code requiring STA, e.g. ASIO backend or winit
drag-and-drop.
To dive into the detail, the entry point of WASAPI, MMDeviceEnumerator, is
registered with "both" threading model, which means that COM objects are
created with whatever the thread's concurrency model is set to. This raises
the concern that when STA is used, marshaling might make audio buffer
operations block on the main thread, breaking continuous audio processing.
However, the implementation actually uses free-threaded marshaller for
interfaces dealing with buffer operations, which effectively bypasses COM's
compatibility marshaling behavior and perform any API calls on the caller's
thread instead. Therefore, the interfaces would operate just fine on either
concurrency model.
For more details on COM's threading model, see [1].
[1] https://thrysoee.dk/InsideCOM+/ch04d.htm
Co-Authored-By: Henrik Rydgård <hrydgard@gmail.com>
CloseRustAudio#59CloseRustAudio#348CloseRustAudio#504CloseRustAudio#530CloseRustAudio#538CloseRustAudio#572
On this page: https://msdn.microsoft.com/en-us/library/windows/desktop/dd370875%28v=vs.85%29.aspx
cpal initializes COM in MTA mode.
The text was updated successfully, but these errors were encountered: