Audio buffer underrun when mouse is moving ?
-
Dear Sirs,
I met a problem. I use QAudioOutput to play PCM data to QIODevice every 10ms for 1764 bytes(44.1k/16bits).
This problem is if I don't move my cursor, audio play is very smooth. However, once I move cursor, ALSA show buffer underrun message till I stop moving cursor. The same issue can reproduce on WIN7 64bits and RPi3.
There is nothing on UI, only one button to play audio.
I use QElapsedTimer to check 10ms time slot, the timing is correct within in 10ms. CPU usage under 10%.
I have no idea how to find the root cause, please help provide some directions.
Appreciate~
-
Hi,
Moving the mouse around on your application implies that the event loop will be processing events. Since you are basically sending audio at 100Hz, you should move that part to another thread that won't be influenced by what happens in the GUI thread.
-
Hi
please see
https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/use such worker approach and it should be smooth at all times.