Hi Jeff,
Jeff Moore wrote: >According to the documentation for CFRunLoopRunInMode(), kCFRunLoopRunFinished is returned whenever the >run loop doesn't have any sources or timers installed on it. That makes me think that there is a problem >with how you are setting things up.
I think you're probably right, but it's not obvious to me what I'm doing wrong. The setup and teardown code is the same code in both the first (working) thread and the second (CPU-spinning) thread.
To make it easier to figure out, I've boiled my code down to a simple unit test. If you compile the standalone .cpp file at the following URL ("g++ coreaudio_unit_test.cpp -framework AudioUnit -framework CoreServices") and run it with no arguments, it should reproduce the problem.
Expected behavior of the unit test: (1) Play an ugly sine wave for 5 seconds, with minimal CPU usage (2) Pause for two seconds of silence (3) Goto (1)
Observed behavior of the unit test (on my 8-core Xeon MacPro, with Leopard/10.5.5): (1) Plays an ugly sine wave for 5 seconds, with minimal CPU usage (2) Pauses for two seconds of silence (3) Plays the ugly sine wave for 5 more seconds, but now it uses 100% CPU on one core, according to Activity Monitor (!!!) (4) Goto (2)
Can anyone reproduce this problem using the program at the URL above? If so, any ideas as to what is going wrong?
Thanks, Jeremy
|