mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
PCM: Avoid busy loop in snd_pcm_write_areas() with rate plugin
snd_pcm_write_areas() tries to wait until avail >= avail_min condition is satisfied. This doesn't work always well when a rate plugin is in the play. When a partial data with a smaller size than a period is written, the rate plugin doesn't transfer the data immediately to the slave PCM, but kept in an internal buffer and it changes only the hwptr of the plugin. Thus, the condition "avail < avail_min" is triggered for a wait check although the underlying slave PCM has enough room. This results in a call of snd_pcm_wait() which returns immediately after poll() call, and the snd_pcm_write_areas() loop continues. As a consequence, it falls into a CPU hog. This patch fixes that busy loop by introducing a new fast_ops to check the availability for wait of avail_min. Then a plugin can ask the slave PCM whether the wait is required (or possible). A few plugins like multi plugin need a special handling. Otherwise a generic plugin function can be used. Reported-by: Trent Piepho <tpiepho@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
49dde08641
commit
3fd4ab9be0
10 changed files with 37 additions and 5 deletions
|
|
@ -545,6 +545,7 @@ static const snd_pcm_fast_ops_t snd_pcm_meter_fast_ops = {
|
|||
.poll_descriptors_count = snd_pcm_generic_poll_descriptors_count,
|
||||
.poll_descriptors = snd_pcm_generic_poll_descriptors,
|
||||
.poll_revents = snd_pcm_generic_poll_revents,
|
||||
.may_wait_for_avail_min = snd_pcm_generic_may_wait_for_avail_min,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue