Runtime of PCM substream has a parameter, avail_min, as a threshold to the amount of available PCM frames in PCM buffer. Usually, this value is shared with user space via mapped page frame. However, when failing the mapping, applications perform fallback operation with SNDRV_PCM_IOCTL_SYNC_PTR.
This commit add a helper function so that the above design is explicit.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- src/pcm/pcm_hw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index a5cc5e46..045e7890 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -160,6 +160,15 @@ static int sync_applptr(snd_pcm_hw_t *hw) return sync_ptr1(hw, &ptr, 0); }
+static int issue_availmin(snd_pcm_hw_t *hw) +{ + if (!hw->mmap_control_fallbacked) + return 0; + + return sync_ptr1(hw, hw->sync_ptr, + SNDRV_PCM_SYNC_PTR_APPL); +} + static int query_applptr(snd_pcm_hw_t *hw) { if (!hw->mmap_control_fallbacked) @@ -495,7 +504,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) params->silence_size == pcm->silence_size && old_period_event == hw->period_event) { hw->mmap_control->avail_min = params->avail_min; - return sync_ptr(hw, 0); + return issue_availmin(hw); } if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW && hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) {