Why use select() instead of sleep()?

后端 未结 6 820
执笔经年
执笔经年 2020-12-31 04:28

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)          


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 05:24

    The real reason to use 'select' instead of 'sleep' is the accuracy of sleep, especially the audio or video playback. Use 'select' can get higher precision time interval for sleeping on linux or windows or other OS than 'sleep'.

    I am surprised that many people actually don't know why. And please stop to shame on the programmer / write of such a code.

提交回复
热议问题