So, make a shared buffer between Audio and GUI, which will work this way.mystran wrote:What you are supposed to do is copy the coefficients from the audio data to a shared buffer in the audio thread if you can get the lock without waiting. You are then supposed to copy those coefficients from the shared buffer into a GUI-side buffer in the GUI thread so that you don't need to hold the lock while you draw.
Audio thread try to copy coeffs to shared buffer:
- if shared buffer is locked (i.e. GUI thread is copying values from shared buffer) skip and go ahead;
- else lock, copy, unlock and go ahead;
GUI thread try to copy coeffs from shared buffer:
- if shared buffer is locked (i.e. Audio thread is copying value to shared buffer) block (and wait), than lock, copy, unlock and draw;
- else lock, copy, unlock and draw;
Right?