ALSA sound experience/interest?

I've just added some very dodgy ALSA sound support to my Linux/xcb platform layer:

https://github.com/nxsy/xcb_handmade

This is the first time I've tried anything to do with sound at this level, so I'm just surprised I got something that mostly works most of the time. It has buffer underruns and more latency than I would like.

It would be awesome if someone with ALSA sound experience could help out - or even just someone interested in learning about it in the deep end.

Thanks!
I just started working on ALSA for my Common Lisp implementation. I'm going the MMAP_INTERLEAVED route, but I'm mostly basing it off of the pcm.c sine wave generator provided in test/pcm.c of the alsa tar-file on the download page.

I also found this document which uses the read/write method that I think you are using:

http://users.suse.com/~mana/alsa090_howto.html

But I didn't read it too much! Good luck :)

Edited by Christopher on
I look forward to seeing your code - I wanted to use MMAP_INTERLEAVED simply because then I could more easily use Casey's Win32 audio code as a template on what to do. But the play/write cursor idea doesn't seem to map directly to MMAP_INTERLEAVED, reducing that benefit, and I could find no useful documentation on it (but then, there isn't anything useful on using snd_pcm_writei in the game/low-latency case, mostly just the music file playback case with ~1-2s of write-ahead).

Cheers!

Neil
I'll see what I can do in the next day or so! I feel pretty close.
Alright so I managed to get a sound test working (it totally dis-regards important errors right now, so don't use this please!).

https://gist.github.com/chebert/a501fc6c67b4ae406eb4

It's not working with Xlib yet (sound is super choppy) so that's next on the list. then at least enough error handling to re-start the sound for buffer over/under runs.

As to the playCursor writeCursor thing that casey does, I think that gets taken care of by ALSA? It seems like the
1
while (> size 0)

takes care of looping over the regions to write to.