All of lore.kernel.org
 help / color / mirror / Atom feed
* ALSA PCM playing stops randomly, write buffer fills up
       [not found] <18af499151927d00-webhooks-bot@alsa-project.org>
@ 2026-05-14  1:14 ` GitHub issues - opened
  0 siblings, 0 replies; 3+ messages in thread
From: GitHub issues - opened @ 2026-05-14  1:14 UTC (permalink / raw)
  To: alsa-devel

alsa-project/alsa-lib issue #506 was opened from brucemack:

Hi:

I have simple ASLA application that exhibits a strange behavior. I would welcome any advice for improved debug techniques.

My program is non-blocking with a single playback handle.
My program is a loop that plays a tone that lasts for 2 seconds, with a 1 second gap.
While the tone is active my program writes a 20ms block of audio (960 PCM samples x 2 channels at 48k) every 20ms. 
My buffer time is set to 320ms (plenty of space).
My start threshold is set to 1200 frames.
The audio hardware is a USB-connected device using a CM108B chip.

My program runs very nicely with good audio quality for several minutes.  The delay/available pointers move around exactly the way I'd expect and the delay never goes above 2000 frames when the tone is playing. Production and consumption of audio are perfectly matched in a smooth stream.

The state also looks good - it moves from XRUN to prepared to running and back to XRUN as the tone starts and stops.

After several minutes, the delay suddenly start to rise (and the available space falls) to the point where snd_pcm_writei() won't accept any more data. It gets stuck like this forever.

Strangely, when I kill the program and restart it everything is fine until this repeats several minutes later.

>From my diagnostic prints (see below) it seems like the play buffer just suddenly stops getting consumed, even though the state is still running (3).

I would be grateful if someone could suggest an idea for diagnosing this problem.

I: 05-14 00:52:00.780 Turning off tone
I: 05-14 00:52:00.800 Playback state change (2801) 3 -> 4 [1536, 14400]
I: 05-14 00:52:00.820 Playback state change (2802) 4 -> 2 [0, 15360]
I: 05-14 00:52:00.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:01.780 Turning on tone
I: 05-14 00:52:01.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:01.820 Playback state change (2852) 2 -> 3 [1536, 14400]
I: 05-14 00:52:01.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:03.780 Turning off tone
I: 05-14 00:52:03.800 Playback state change (2951) 3 -> 4 [1536, 14400]
I: 05-14 00:52:03.820 Playback state change (2952) 4 -> 2 [0, 15360]
I: 05-14 00:52:03.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:04.780 Turning on tone
I: 05-14 00:52:04.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:04.820 Playback state change (3002) 2 -> 3 [1536, 14400]
I: 05-14 00:52:04.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:06.780 Turning off tone
I: 05-14 00:52:06.800 Playback state change (3101) 3 -> 4 [1536, 14400]
I: 05-14 00:52:06.820 Playback state change (3102) 4 -> 2 [0, 15360]
I: 05-14 00:52:06.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:07.780 Turning on tone
I: 05-14 00:52:07.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:07.820 Playback state change (3152) 2 -> 3 [1536, 14400]
I: 05-14 00:52:07.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:09.780 Turning off tone
I: 05-14 00:52:09.800 Playback state change (3251) 3 -> 4 [1536, 14400]
I: 05-14 00:52:09.820 Playback state change (3252) 4 -> 2 [0, 15360]
I: 05-14 00:52:09.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:10.780 Turning on tone
I: 05-14 00:52:10.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:10.820 Playback state change (3302) 2 -> 3 [1920, 13440]

**PROBLEM STARTS HERE**

I: 05-14 00:52:10.820 Delay/avail 1920 / 13440 frames
I: 05-14 00:52:10.840 Delay/avail 2880 / 12480 frames
I: 05-14 00:52:10.860 Delay/avail 3840 / 11520 frames
I: 05-14 00:52:10.880 Delay/avail 4800 / 10560 frames
I: 05-14 00:52:10.900 Delay/avail 5760 / 9600 frames
I: 05-14 00:52:10.920 Delay/avail 6720 / 8640 frames
I: 05-14 00:52:10.940 Delay/avail 7680 / 7680 frames
I: 05-14 00:52:10.960 Delay/avail 8640 / 6720 frames
I: 05-14 00:52:10.980 Delay/avail 9600 / 5760 frames
I: 05-14 00:52:10.000 Delay/avail 10560 / 4800 frames
E: 05-14 00:52:10.000 Delay is growing
I: 05-14 00:52:11.220 Delay/avail 11520 / 3840 frames
E: 05-14 00:52:11.220 Delay is growing
I: 05-14 00:52:11.440 Delay/avail 12480 / 2880 frames
E: 05-14 00:52:11.440 Delay is growing
I: 05-14 00:52:11.660 Delay/avail 13440 / 1920 frames
E: 05-14 00:52:11.660 Delay is growing
I: 05-14 00:52:11.880 Delay/avail 14400 / 960 frames
E: 05-14 00:52:11.880 Delay is growing
I: 05-14 00:52:12.100 Delay/avail 15360 / 0 frames
E: 05-14 00:52:12.100 Delay is growing
E: 05-14 00:52:12.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:12.780 Turning off tone
I: 05-14 00:52:13.781 Turning on tone
E: 05-14 00:52:14.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:15.780 Turning off tone
I: 05-14 00:52:16.780 Turning on tone
E: 05-14 00:52:16.781 USB BUFFER FULL, state 3 15360 0

Issue URL     : https://github.com/alsa-project/alsa-lib/issues/506
Repository URL: https://github.com/alsa-project/alsa-lib

^ permalink raw reply	[flat|nested] 3+ messages in thread

* ALSA PCM playing stops randomly, write buffer fills up
       [not found] <18af49aba6bce900-webhooks-bot@alsa-project.org>
@ 2026-05-14  1:16 ` GitHub issues - edited
  0 siblings, 0 replies; 3+ messages in thread
From: GitHub issues - edited @ 2026-05-14  1:16 UTC (permalink / raw)
  To: alsa-devel

alsa-project/alsa-lib issue #506 was edited from brucemack:

Hi:

I have simple ASLA application that exhibits a strange behavior. I would welcome any advice for improved debug techniques.

My program is non-blocking with a single playback handle.
My program is a loop that plays a tone that lasts for 2 seconds, with a 1 second gap.
While the tone is active my program writes a 20ms block of audio (960 PCM samples x 2 channels at 48k) every 20ms. 
My buffer time is set to 320ms (plenty of space).
My start threshold is set to 1200 frames.
The audio hardware is a USB-connected device using a CM108B chip.

My program runs very nicely with good audio quality for several minutes.  The delay/available pointers move around exactly the way I'd expect and the delay never goes above 2000 frames when the tone is playing. Production and consumption of audio are perfectly matched in a smooth stream.

The state also looks good - it moves from XRUN to prepared to running and back to XRUN as the tone starts and stops.

After several minutes, the delay suddenly start to rise (and the available space falls) to the point where snd_pcm_writei() won't accept any more data. It gets stuck like this forever.

Strangely, when I kill the program and restart it everything is fine until this repeats several minutes later.

>From my diagnostic prints (see below) it seems like the play buffer just suddenly stops getting consumed, even though the state is still running (3).

I would be grateful if someone could suggest an idea for diagnosing this problem.

arduino@Q1:~/amp-server/build$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k6.16.7-g0dd6551ae96b.

I: 05-14 00:52:00.780 Turning off tone
I: 05-14 00:52:00.800 Playback state change (2801) 3 -> 4 [1536, 14400]
I: 05-14 00:52:00.820 Playback state change (2802) 4 -> 2 [0, 15360]
I: 05-14 00:52:00.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:01.780 Turning on tone
I: 05-14 00:52:01.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:01.820 Playback state change (2852) 2 -> 3 [1536, 14400]
I: 05-14 00:52:01.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:03.780 Turning off tone
I: 05-14 00:52:03.800 Playback state change (2951) 3 -> 4 [1536, 14400]
I: 05-14 00:52:03.820 Playback state change (2952) 4 -> 2 [0, 15360]
I: 05-14 00:52:03.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:04.780 Turning on tone
I: 05-14 00:52:04.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:04.820 Playback state change (3002) 2 -> 3 [1536, 14400]
I: 05-14 00:52:04.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:06.780 Turning off tone
I: 05-14 00:52:06.800 Playback state change (3101) 3 -> 4 [1536, 14400]
I: 05-14 00:52:06.820 Playback state change (3102) 4 -> 2 [0, 15360]
I: 05-14 00:52:06.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:07.780 Turning on tone
I: 05-14 00:52:07.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:07.820 Playback state change (3152) 2 -> 3 [1536, 14400]
I: 05-14 00:52:07.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:09.780 Turning off tone
I: 05-14 00:52:09.800 Playback state change (3251) 3 -> 4 [1536, 14400]
I: 05-14 00:52:09.820 Playback state change (3252) 4 -> 2 [0, 15360]
I: 05-14 00:52:09.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:10.780 Turning on tone
I: 05-14 00:52:10.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:10.820 Playback state change (3302) 2 -> 3 [1920, 13440]

**PROBLEM STARTS HERE**

I: 05-14 00:52:10.820 Delay/avail 1920 / 13440 frames
I: 05-14 00:52:10.840 Delay/avail 2880 / 12480 frames
I: 05-14 00:52:10.860 Delay/avail 3840 / 11520 frames
I: 05-14 00:52:10.880 Delay/avail 4800 / 10560 frames
I: 05-14 00:52:10.900 Delay/avail 5760 / 9600 frames
I: 05-14 00:52:10.920 Delay/avail 6720 / 8640 frames
I: 05-14 00:52:10.940 Delay/avail 7680 / 7680 frames
I: 05-14 00:52:10.960 Delay/avail 8640 / 6720 frames
I: 05-14 00:52:10.980 Delay/avail 9600 / 5760 frames
I: 05-14 00:52:10.000 Delay/avail 10560 / 4800 frames
E: 05-14 00:52:10.000 Delay is growing
I: 05-14 00:52:11.220 Delay/avail 11520 / 3840 frames
E: 05-14 00:52:11.220 Delay is growing
I: 05-14 00:52:11.440 Delay/avail 12480 / 2880 frames
E: 05-14 00:52:11.440 Delay is growing
I: 05-14 00:52:11.660 Delay/avail 13440 / 1920 frames
E: 05-14 00:52:11.660 Delay is growing
I: 05-14 00:52:11.880 Delay/avail 14400 / 960 frames
E: 05-14 00:52:11.880 Delay is growing
I: 05-14 00:52:12.100 Delay/avail 15360 / 0 frames
E: 05-14 00:52:12.100 Delay is growing
E: 05-14 00:52:12.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:12.780 Turning off tone
I: 05-14 00:52:13.781 Turning on tone
E: 05-14 00:52:14.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:15.780 Turning off tone
I: 05-14 00:52:16.780 Turning on tone
E: 05-14 00:52:16.781 USB BUFFER FULL, state 3 15360 0

Issue URL     : https://github.com/alsa-project/alsa-lib/issues/506
Repository URL: https://github.com/alsa-project/alsa-lib

^ permalink raw reply	[flat|nested] 3+ messages in thread

* ALSA PCM playing stops randomly, write buffer fills up
       [not found] <18af7231e680fa00-webhooks-bot@alsa-project.org>
@ 2026-05-14 13:38 ` GitHub issues - edited
  0 siblings, 0 replies; 3+ messages in thread
From: GitHub issues - edited @ 2026-05-14 13:38 UTC (permalink / raw)
  To: alsa-devel

alsa-project/alsa-lib issue #506 was edited from brucemack:

Hi:

I have simple ASLA application that exhibits a strange behavior. I would welcome any advice for improved debug techniques.

My program is non-blocking with a single playback handle.
My program is a loop that plays a tone that lasts for 2 seconds, with a 1 second gap.
While the tone is active my program writes a 20ms block of audio (960 PCM samples x 2 channels at 48k) every 20ms. 
My buffer time is set to 320ms (plenty of space).
My start threshold is set to 1200 frames.
The audio hardware is a USB-connected device using a CM108B chip.

My program runs very nicely with good audio quality for several minutes.  The delay/available pointers move around exactly the way I'd expect and the delay never goes above 2000 frames when the tone is playing. Production and consumption of audio are perfectly matched in a smooth stream.

The state also looks good - it moves from XRUN to prepared to running and back to XRUN as the tone starts and stops.

After several minutes, the delay suddenly starts to rise (and the available space falls) to the point where snd_pcm_writei() won't accept any more data. It gets stuck like this forever.

Strangely, when I kill the program and restart it everything is fine until this repeats several minutes later.

>From my diagnostic prints (see below) it seems like the play buffer just suddenly stops getting consumed, even though the state is still running (3).

I would be grateful if someone could suggest an idea for diagnosing this problem.

arduino@Q1:~/amp-server/build$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k6.16.7-g0dd6551ae96b.

I: 05-14 00:52:00.780 Turning off tone
I: 05-14 00:52:00.800 Playback state change (2801) 3 -> 4 [1536, 14400]
I: 05-14 00:52:00.820 Playback state change (2802) 4 -> 2 [0, 15360]
I: 05-14 00:52:00.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:01.780 Turning on tone
I: 05-14 00:52:01.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:01.820 Playback state change (2852) 2 -> 3 [1536, 14400]
I: 05-14 00:52:01.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:03.780 Turning off tone
I: 05-14 00:52:03.800 Playback state change (2951) 3 -> 4 [1536, 14400]
I: 05-14 00:52:03.820 Playback state change (2952) 4 -> 2 [0, 15360]
I: 05-14 00:52:03.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:04.780 Turning on tone
I: 05-14 00:52:04.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:04.820 Playback state change (3002) 2 -> 3 [1536, 14400]
I: 05-14 00:52:04.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:06.780 Turning off tone
I: 05-14 00:52:06.800 Playback state change (3101) 3 -> 4 [1536, 14400]
I: 05-14 00:52:06.820 Playback state change (3102) 4 -> 2 [0, 15360]
I: 05-14 00:52:06.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:07.780 Turning on tone
I: 05-14 00:52:07.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:07.820 Playback state change (3152) 2 -> 3 [1536, 14400]
I: 05-14 00:52:07.820 Delay/avail 1536 / 14400 frames
I: 05-14 00:52:09.780 Turning off tone
I: 05-14 00:52:09.800 Playback state change (3251) 3 -> 4 [1536, 14400]
I: 05-14 00:52:09.820 Playback state change (3252) 4 -> 2 [0, 15360]
I: 05-14 00:52:09.820 Delay/avail 0 / 15360 frames
I: 05-14 00:52:10.780 Turning on tone
I: 05-14 00:52:10.800 Delay/avail 960 / 14400 frames
I: 05-14 00:52:10.820 Playback state change (3302) 2 -> 3 [1920, 13440]

**PROBLEM STARTS HERE**

I: 05-14 00:52:10.820 Delay/avail 1920 / 13440 frames
I: 05-14 00:52:10.840 Delay/avail 2880 / 12480 frames
I: 05-14 00:52:10.860 Delay/avail 3840 / 11520 frames
I: 05-14 00:52:10.880 Delay/avail 4800 / 10560 frames
I: 05-14 00:52:10.900 Delay/avail 5760 / 9600 frames
I: 05-14 00:52:10.920 Delay/avail 6720 / 8640 frames
I: 05-14 00:52:10.940 Delay/avail 7680 / 7680 frames
I: 05-14 00:52:10.960 Delay/avail 8640 / 6720 frames
I: 05-14 00:52:10.980 Delay/avail 9600 / 5760 frames
I: 05-14 00:52:10.000 Delay/avail 10560 / 4800 frames
E: 05-14 00:52:10.000 Delay is growing
I: 05-14 00:52:11.220 Delay/avail 11520 / 3840 frames
E: 05-14 00:52:11.220 Delay is growing
I: 05-14 00:52:11.440 Delay/avail 12480 / 2880 frames
E: 05-14 00:52:11.440 Delay is growing
I: 05-14 00:52:11.660 Delay/avail 13440 / 1920 frames
E: 05-14 00:52:11.660 Delay is growing
I: 05-14 00:52:11.880 Delay/avail 14400 / 960 frames
E: 05-14 00:52:11.880 Delay is growing
I: 05-14 00:52:12.100 Delay/avail 15360 / 0 frames
E: 05-14 00:52:12.100 Delay is growing
E: 05-14 00:52:12.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:12.780 Turning off tone
I: 05-14 00:52:13.781 Turning on tone
E: 05-14 00:52:14.300 USB BUFFER FULL, state 3 15360 0
I: 05-14 00:52:15.780 Turning off tone
I: 05-14 00:52:16.780 Turning on tone
E: 05-14 00:52:16.781 USB BUFFER FULL, state 3 15360 0

Issue URL     : https://github.com/alsa-project/alsa-lib/issues/506
Repository URL: https://github.com/alsa-project/alsa-lib

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-14 13:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <18af7231e680fa00-webhooks-bot@alsa-project.org>
2026-05-14 13:38 ` ALSA PCM playing stops randomly, write buffer fills up GitHub issues - edited
     [not found] <18af49aba6bce900-webhooks-bot@alsa-project.org>
2026-05-14  1:16 ` GitHub issues - edited
     [not found] <18af499151927d00-webhooks-bot@alsa-project.org>
2026-05-14  1:14 ` GitHub issues - opened

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.