I'm working through a chapter about iPhone audio and have come across a section of code that I can't make sense of:
while (aqc.playPtr < aqc.sampleLen)
{
select(NULL, NULL, NULL, NULL, 1.0);
}
(Full code sample is on pages 163-166). From what I understand of the code the audio is being processed on another thread and the while loop is just there to prevent the main thread from terminating while audio is still being processed.
What I don't understand is why select()
is being used instead of sleep()
.
From what I've read select()
is used to monitor changes in I/O and passing it NULLs doesn't do anything meaningful. I've ran the code using sleep()
and it works as expected. (My knowledge of low level POSIX is almost non-existant.)