#define PERIOD 6000
#define PLAYBACK_BUFFERS 4
unsigned char buffer_p[PERIOD*4*4]; unsigned char buffer_c[PERIOD*4*4];
I don't understand why you hard coded PERIOD and PLAYBACK_BUFFERS when you use snd_pcm_set_params
Thanks for pointing this out. I have no idea what this is still there, i think the idea was to use a fixed-size buffer to make sure the timing is predictable, it's been that way for 2+ years. Will fix.
since period size and buffer size can be obtained by snd_pcm_get_params() after calling snd_pcm_set_params()
if ((err = snd_pcm_set_params(handle_p, SND_PCM_FORMAT_S16, SND_PCM_ACCESS_RW_INTERLEAVED, 2, 48000, 0, 500000)) < 0) { /* 0.5sec */