Fix sound cutoff for looped sounds and make sound offset threshold depen...

...dent on the size of the audio buffer