Ferenc Engárd wrote: > The program writes 3*1000 samples, then drains, sleeps 1 second, and loops. My example output running this program: > > fery@fery-E6540:~/tmp/alsa-demo/alsa-underrun-demo$ g++ -o alsa-test alsa-test.cpp -lasound && ./alsa-test > SOUND: setupWithFreq sampling rate: 44100 > SOUND: number of periods: 3 > SOUND: period size: 1000 frames > 0 {0} > 1 {1} > ALSA error: Broken pipe > ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred > 1 {2} Are you using PulseAudio? Does the same happen if you use the device name "plughw"? > is it safe to write fewer samples than period size, Yes. > even if it is not the last pcm_writei in the stream? snd_pcm_drain() detects the end only on a period boundary, so the last write should not leave a period partially unfilled. Regards, Clemens ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford _______________________________________________ Alsa-user mailing list Alsa-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-user