In the past I have found locks straight forward enough but I have need to pass data between Graphics and Audio Thread but I can’t in this example set a flag and poll so I need to use a lock. The operation is infrequent with little chance of contention but for app stability I think it’s necessary.
How do I set a mutex where the graphics thread is the owner of the mutex. Lock the thread whilst in the audio callback loop and occasionally lock on graphics thread (being the owner) and keep it all within an RAII style pattern?
(It’s the mutex being on the UI thread that’s causing undefined behaviour)