Playing silence instead of pausing during underrun
If I understand it correctly, when ALSA detects an underrun during playback, it throttles the driver by sending pause and resume commands.
It turns out that our hardware doesn't really like this. We're looking at various solutions, but one proposal would be to keep the hardware running during a pause, but just have it play silence instead. That is, ALSA keeps feeding silence data during an underrun recovery.
Is there an easy way to do this in ALSA? Is there another driver that does this?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 10 lines · Timur Tabi
If I understand it correctly, when ALSA detects an underrun during playback, it throttles the driver by sending pause and resume commands.
It turns out that our hardware doesn't really like this. We're looking at various solutions, but one proposal would be to keep the hardware running during a pause, but just have it play silence instead. That is, ALSA keeps feeding silence data during an underrun recovery.
Is there an easy way to do this in ALSA? Is there another driver that does this?
Note that not all hardware supports pause, so just remove SNDRV_PCM_INFO_PAUSE and all pause related code in the trigger callback and let user space to do the full reinitialization.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 3 lines · Jaroslav Kysela
Note that not all hardware supports pause, so just remove
SNDRV_PCM_INFO_PAUSEand all pause related code in the trigger callback and let user space to do the full reinitialization.
That's not what I'm talking about. It doesn't matter if it's paused or stopped, when playback is paused/stopped, the hardware is disabled.
When the hardware is re-enabled, stale data in the hardware causes a
popping sound. Therefore, during underrun, the popping will not occur if the hardware is never disabled, but this requires either the driver or ALSA to pump silence data into the hardware.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
At Thu, 4 Sep 2008 11:04:55 -0500,
Quoted 7 lines · Timur Tabi
Quoted 3 lines · Jaroslav Kysela
Note that not all hardware supports pause, so just remove
SNDRV_PCM_INFO_PAUSEand all pause related code in the trigger callback and let user space to do the full reinitialization.
Quoted 6 lines
That's not what I'm talking about. It doesn't matter if it's paused or stopped, when playback is paused/stopped, the hardware is disabled.
When the hardware is re-enabled, stale data in the hardware causes a
popping sound. Therefore, during underrun, the popping will not occur if the hardware is never disabled, but this requires either the driver or ALSA to pump silence data into the hardware.
Right now there is no common mechanism in the ALSA PCM core for that. This might be a good thing to have such in the common place, though. Or, we should reconsider the current mechanism of triggering. There are some other known problems regarding it.
For normal case to restart the stream, you can have a workaround in prepare callback (prepare callback is always called before start-trigger). That is, if the stream was stopped in a certain condition, set some flag. In prepare callback, you first check this flag, and fill silence if set, then clear the flag. This doesn't work for pause-resume, though.
The reason to put it in prepare callback is that trigger is supposed to be atomic.
Takashi