mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-07 13:30:07 -05:00
pcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()
- improve readability - pass slave hw_ptr as argument - improves the code flow Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
76659453ef
commit
d0ebce5928
5 changed files with 16 additions and 22 deletions
|
|
@ -2120,22 +2120,22 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void snd_pcm_direct_reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix)
|
||||
void snd_pcm_direct_reset_slave_ptr(snd_pcm_t *pcm, snd_pcm_direct_t *dmix,
|
||||
snd_pcm_uframes_t hw_ptr)
|
||||
{
|
||||
|
||||
dmix->slave_appl_ptr = dmix->slave_hw_ptr = hw_ptr;
|
||||
if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDUP ||
|
||||
(dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO &&
|
||||
pcm->buffer_size <= pcm->period_size * 2))
|
||||
(dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO &&
|
||||
pcm->buffer_size <= pcm->period_size * 2))
|
||||
dmix->slave_appl_ptr =
|
||||
((dmix->slave_appl_ptr + dmix->slave_period_size - 1) /
|
||||
dmix->slave_period_size) * dmix->slave_period_size;
|
||||
dmix->slave_period_size) * dmix->slave_period_size;
|
||||
else if (dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_ROUNDDOWN ||
|
||||
(dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO &&
|
||||
(dmix->slave_period_size * SEC_TO_MS) /
|
||||
pcm->rate < LOW_LATENCY_PERIOD_TIME))
|
||||
(dmix->hw_ptr_alignment == SND_PCM_HW_PTR_ALIGNMENT_AUTO &&
|
||||
((dmix->slave_period_size * SEC_TO_MS) / pcm->rate) < LOW_LATENCY_PERIOD_TIME))
|
||||
dmix->slave_appl_ptr = dmix->slave_hw_ptr =
|
||||
((dmix->slave_hw_ptr / dmix->slave_period_size) *
|
||||
dmix->slave_period_size);
|
||||
dmix->slave_period_size);
|
||||
}
|
||||
|
||||
int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue