Hello ALSA community.
I'm an User-Space application developer, using the ALSA library to play mixed sounds. My application (and for that matter also aplay) are having one underrun problem, and I need help on how to interpret the following debug information and receive some possible workarounds/solutions.
The underrun occurs only: once after writei() was performed with get_buffer_size bytes written, and try to do another writei().
Target: Fujitsu Jade microcontroller
ALSA: 1.0.25
ALSA PCM interface for Jade-xxsvideo: /kernel/linux-2.6.31.4/sound/soc/xxsvideo/jade-pcm.c
DMA driver: /kernel/linux-2.6.31.4/arch/arm/mach-xxsvideo/dma.c
Here are the traces I managed to do, if there is any other information needed, please ask me for it.
Application trace: [line: 1297 ]: Trying to open the ALSA plugin = plug:'dmix:RATE=8000' [463379 ms] : Play ThreadID [1126167328]: before open ALSA [line: 1313 ]: Play Sound No: 0, Sound name: Snd_000.wav - from Thread-ID: 1126167328 [463417 ms] : Play ThreadID [1126167328]: before setting parameters [line: 1377 ]: 16 Bit format [line: 1386 ]: Channel count: 1 [line: 1394 ]: Sample rate: 8000 [line: 1473 ]: Period size = 1024 ; Buffer size = 4096 [line: 1514 ]: Start threshold = 4096 [463441 ms] : Play ThreadID [1126167328]: after parmas ended [463442 ms] : Play ThreadID [1126167328]: before malloc [463442 ms] : Play ThreadID [1126167328]: before reading/writing [line: 1691 ]: Writei() ended, bytes written = 2048, available bytes to be written = 2048 [line: 1691 ]: Writei() ended, bytes written = 2048, available bytes to be written = 48 underrun!!! (at least 0.019 ms long) [line: 1660 ]: Underrun encountered: status = -32 ALSA lib pcm.c:7339:(snd_pcm_recover) underrun occurred [line: 1691 ]: Writei() ended, bytes written = 0, available bytes to be written = 4096 [line: 1691 ]: Writei() ended, bytes written = 2048, available bytes to be written = 2048 [line: 1615 ]: Add silence in last buffer, with size = 1948 [line: 1691 ]: Writei() ended, bytes written = 2048, available bytes to be written = 64 [463526 ms] : Play ThreadID [1126167328]: after reading/writing fully ended [464152 ms] : Play ThreadID [1126167328]: after ALSA drain
X_RUN DEBUG TRACE: echo 1 > /proc/asound/card0/pcm0p/xrun_debug
ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:330: PCM: Lost interrupts? (stream=0, delta=15360, intr_ptr=1024) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=0, intr_ptr=17408) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=1024, intr_ptr=18432) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=2048, intr_ptr=19456) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=3072, intr_ptr=20480) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=4096, intr_ptr=21504) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=5120, intr_ptr=22528) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=6144, intr_ptr=23552) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=7168, intr_ptr=24576) ALSA /home/kernel/linux-2.6.31.4/sound/core/pcm_lib.c:266: PCM: Unexpected hw_pointer value (stream=0, pos=8192, intr_ptr=25600)
Additional note: using the : #echo 2 > /proc/asound/card0/pcm0p/xrun_debug there are no more underruns occurrences!! And this seems to be normal, according to Procfile.txt description from Takashi Iwai (...can be lead to too much corrections for a (mostly buggy) hardware that doesn't give smooth pointer updates)
Thank you for any information and help given.