Mysterious audioCallback CPU eating phenomena


#1

I’m stuck with a problem that I can’t seem to solve: I’ve noticed that whenever a lot of painting goes on in my app, the CPU usage inside the audioDeviceIOCallback() goes up, which seems weird, as the GUI thread has lower priority. So whenever I move or zoom a lot in my sequencer, the shown CPU usage goes up. I’ve gone so far to create an animated component of huge size (800x800) that paints when one clicks on it and stops again when one clicks on it, and I can clearly see that whenever the animation is going on, the CPU usage inside the ASIO callback goes up.

How is this possible? I’ve tried lowering the GUI thread’s priority, it doesn’t help. I’ve also tried increasing the process’ priority, it doesn’t help either.

A few more things to note:

  • On the same machine with Ableton Live, even under heavy ASIO CPU usage, the same problem cannot be seen, so I can move things around and zoom as much as I like, it doesn’t change the ASIO callback CPU usage. It is also worth to note that Ableton never did produce any audio dropouts/crackles when zooming stuff.
  • Another weird thing is that when I check CPU usage in the Task Manager while zooming in my sequencer, CPU usage goes up on both processor cores. That doesn’t make any sense to me either, because the GUI thread can only be running on 1 single core at the same time, or am I wrong?
  • Zooming in my sequencer also led to heavy audio drops and crackles, but after I set the component that gets redrawn (the MIDI key editor) to be opaque, the audio drops were gone, although the CPU usage in the ASIO callback stayed the same.

My machine is a dual Pentium4 3.2GHz on Windows XP SP2. This was with JUCE146, but I’ll try with 151 soon. I’ve tried with the onboard graphics card, and an NVIDIA card. It’s always the same. So, I don’t think the problem is related to the graphics card.


#2

I’ve sorted out the problem. In the Task Manager I’ve noticed that on my machine, Ableton only uses 1 processor core (although I have 2). So I’ve called setCurrentThreadAffinityMask(1) in both the GUI thread and the ASIO callback (only once, when it gets called the first time) and the problem magically got away. I’ve got one of these great HyperThreading processors, maybe it’s due to that? What kind of Voodoo is going on ?


#3

I don’t like the sound of that, it is a hardware-specific solution. I agree, it would be good to figure out what is really going on. Do you have any other applications going? You mentioned Ableton, is that running along with your application? If two or more programs are sharing an interrupt-driven resource it could lead to the problems you described.


#4

No, no other apps were running. I always tried my app, closed it, then run Ableton. My soundcard hasn’t a multiclient ASIO driver anyway. The only thing I can think of is that there is some lock shared by the message (GUI) thread and the audio processing thread that hinders the audio processing thread from starting immediately. I’ll try to find out.


#5

Disabled Hyperthreading in the BIOS and seems to be ok now.