I am doing a VoIP program which continously checks whether the audio-recording buffer has anything in it (FMOD library, whenever the function getRecordPosition > 0, then the buffer has data in it).
So it would be something along the lines of:
while (true) {
if(getRecordPosition>0) {
process data....
}
}
However this would cause a very high CPU usage. One version would be to use sleep() but I'd rather not use it if possible. For example the win32 messagehandling with its event-driven loop dosn't consume many cpu cycles and it's something I'm trying to emulate. At the same time I understand the function getRecordPosition() would have to be called frequently to see if the return value gets above 0.
Am I stuck with doing a while(true) loop and sleep() for some small amount of time in order to keep low-CPU usage?
I've googled and done some lookup but most returns either using sleep() or some POSIX synchronization with mutex. (I am doing a c++ win32 app)
Cheers
---EDIT: Forgot to mention I dont have access to fmod source corde :/ ---