Hi all,
Welcome everybody, as this is my first mail to the list.
I am trying to write my first ALSA audio program, and I have intermittent issues I can't explain.
I am playing ~68ms of sound from memory, in 1-channel U8 setup, and quite frequently I get the following errors:
ALSA error: Broken pipe
ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
The test project can be found here: https://github.com/circum1/alsa-underrun-demo
Compile simply with g++ -o alsa-test alsa-test.cpp -lasound
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-testSOUND: setupWithFreq sampling rate: 44100SOUND: number of periods: 3SOUND: period size: 1000 frames0 {0}1 {1}ALSA error: Broken pipeALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred1 {2}1 before drain48 after drain1049 {0}1050 {1}1050 {2}1050 before drain1119 after drain2120 {0}2121 {1}ALSA error: Broken pipeALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred2121 {2}ALSA error: Broken pipeALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred2122 before drain2122 after drain3123 {0}3124 {1}3124 {2}3124 before drain3194 after drain4195 {0}4195 {1}4195 {2}4195 before drain4265 after drain5266 {0}5266 {1}ALSA error: Broken pipeALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred5267 {2}ALSA error: Broken pipeALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred5268 before drain5268 after drain6269 {0}6270 {1}6270 {2}6270 before drain6339 after drain^C
The numbers at the beginning of the lines are elapsed milliseconds. It is visible that the program writes 2000 samples in 1-2ms, but nevertheless the underrun occurs.
I don't know if the error is in my code, or is it some bug or maybe hw issue?
Possibly relevant env info:
Ubuntu 16.04, Linux version 4.4.0-59-generic
libasound2: Version: 1.1.0-0ubuntu1
pulseaudio: Version: 1:8.0-0ubuntu3.2
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
(Dell E6540 notebook)
Independent of this issue, I also have another question: is it safe to write fewer samples than period size, even if it is not the last pcm_writei in the stream?
Thanks in advance,
Ferenc
------------------------------------------------------------------------------ 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