I finally have my basic audio applications working. I divided it into capture and playback and began with playback as I had a nice sinewave I could use to playback. Anyway, I think my hangup with getting the thing working was with the buffer and period information. My apps now do this:
int periods = 2; /* Number of periods */ snd_pcm_uframes_t periodsize = 1000; /* Periodsize (bytes) */
/* Set number of periods */ if (snd_pcm_hw_params_set_periods(pcm_handle, hwparams, periods, 0) < 0) { fprintf(stderr, "Error setting periods.\n"); return(-1); } /* Set buffer size */ size = periodsize * periods; if (snd_pcm_hw_params_set_buffer_size(pcm_handle, hwparams, (size)>>2) < 0) { fprintf(stderr, "Error setting buffer size.\n"); return(-1); }
I borrowed the period size from using aplay -v and seeing what it used. Setting number of periods to 2 was a little bit of guess work based on what others seem to use. I have looked at the alsa documentation and cannot see how I could have determined these numbers would have worked without trial and error. Can anyone either give me a explanation of how to determine these or a pointer to some decent documentation that talks about this?
Thanks.
Paul