how do i know the amount of sleep(ms) after filling one of the buffer half ?

im getting problems, the sound is breaking sometime