Page 1 of 1
Delay() Question
Posted: Thu Nov 18, 2010 5:02 pm
by chris319
I'm not sure if this is a bug.
The following code:
causes the OS X Activity Monitor to show the process as "Not Responding", whereas in Windows it does not.
I am writing a program which involves repeated calls to either Delay() or WaitWindowEvent(). It works for a while, then locks up.
Re: Delay() Question
Posted: Fri Nov 19, 2010 8:49 am
by chris319
I think I have identified my problem. I was using a window timer and that seemed to have destabilized everything. Maybe the Mac window timer needs to be looked into. I concocted a workaround using threads and Delay().
Re: Delay() Question
Posted: Fri Nov 19, 2010 7:03 pm
by WilliamL
That's interesting. I've used the window timer in simple programs and haven't had any problems. I remember reading that using Delay can interfere with the event loop but I can't remember how so I've been avoiding using Delay. Maybe combining the two were a problem.
If you can make a short piece of code demonstrating the problem, post it as a bug.
Re: Delay() Question
Posted: Sat Nov 20, 2010 8:22 am
by chris319
Well, the program I'm using this in is kind of elaborate as it uses PortAudio which has a callback function to handle audio capture, so making a simple demo would not be straightforward. I will see if I can write a program with a timer specifically for the purpose of causing a failure.
Re: Delay() Question
Posted: Sat Nov 20, 2010 6:08 pm
by WilliamL
I understand. I think we've all run into that dilemma.
The Mac version of PB is still evolving and I'm glad to hear you have a 'work-around'.
Re: Delay() Question
Posted: Sat Nov 20, 2010 8:26 pm
by freak
This is normal. If you use a GUI and you don't call WaitWindowEvent() on a regular basis, then the OS will assume that your program is not responding because... well, it actually is not responding to GUI messages. That is what WaitWindowEvent() does.
Re: Delay() Question
Posted: Sun Nov 21, 2010 1:51 am
by chris319
My workarounds didn't work very well so I rewrote the program using PortAudio's blocking interface instead of the callback interface. Luckily it wasn't difficult to do. It is now much more stable. The code now looks like so:
Code: Select all
Repeat
//Call PortAudio function which returns when audio buffer is full
event = WindowEvent()
//Process window events
Forever
The CPU usage is about half of what it was using the PortAudio callback interface (now about 4% - 5%).