I know that write() is blocking, but the original source used this (rather dodgy) OSS code to avoid blocking
audio_buf_info info;
if (!Settings.ThreadSound &&
(ioctl (so.sound_fd, SNDCTL_DSP_GETOSPACE, &info) == -1 ||
info.bytes < so.buffer_size))
{
//printf("%d ,%d *****\n",info.bytes,so.buffer_size);
return (NULL);
}
edit: libao has no equivalent, and cannot use a callback