[alsa-devel] [PATCH] aplay: support no period wakeup option in argument

Takashi Sakamoto o-takashi at sakamocchi.jp
Thu Dec 27 12:58:01 CET 2018


Hi,

On Thu, Dec 27, 2018 at 06:46:57AM +0000, S.j. Wang wrote:
> I still have two questions:
> 1. It seems the no-period-wakeup feature should be dropped for it isn't recommended
>    By alsa, right?  I still found some driver in kernel support it, what's the reason?
 
You can see the driver supports 'period-wakeup' runtime as well as
'no-period-wakeup' runtime. The driver likely includes a condition
statement to check 'struct snd_pcm_runtime.no_period_wakeup' flag,
then it switches own behaviour for both cases.

Please keep it in your mind that 'period-wakeup' runtime is a
default. At present, there's no way for drivers to tell userspace
applications that 'period-wakeup' runtime is not supported.

> 2. Shall we add this option in aplay for it is feature that alsa support, even it is optional?

Initially 'no-period-wakeup' runtime was introduced to achieve
timer-based scheduling model[1]. Current design of aplay is not
suitable to this model in many points (e.g. value of timeout
argument in each call of poll(2) system call). If adopting
aplay to the model, heavy refactoring is required. For this
reason, I'm not positive to your idea. It's not practical.

However, just configuring hardware parameter with 'no-period-wakeup'
flag, it's possible, as you posted. In this case, you misses some
issues. At least:
 - alsa-lib configures the flag just for non-blocking operation.
 - alsa-lib calls poll(2) without timeout in many parts. When
   configuring the flag to PCM runtime, no tasks and IRQ contexts
   awaken the sleep process. Therefore processing of PCM frame is
   blocked forever in some cases.

(A call of 'snd_pcm_sw_params_set_period_event()' expects 'hw' PCM
plugin in alsa-lib to use ALSA timer interface for 'emulated'
periodical wakeup, however an instance of timer is for the PCM
runtime with 'no-period-wakeup' thus it can't awakens the sleep
process. I think this is a bug in alsa-lib.)

[1] http://0pointer.de/blog/projects/pulse-glitch-free.html
[2] https://github.com/alsa-project/alsa-utils/blob/master/axfer/xfer-libasound-timer-mmap.c#L22


Thanks

Takashi Sakamoto


More information about the Alsa-devel mailing list