@@ -151,6 +151,20 @@ static int sync_ptr(snd_pcm_hw_t *hw, unsigned int flags)
return 0;
}
+static int query_state(snd_pcm_hw_t *hw)
+{
+ if (!hw->mmap_status_fallbacked)
+ return 0;
+
+ /*
+ * Query both of control/status data to avoid unexpected change of
+ * control data in kernel space.
+ */
+ return sync_ptr1(hw,
+ SNDRV_PCM_SYNC_PTR_APPL |
+ SNDRV_PCM_SYNC_PTR_AVAIL_MIN);
+}
+
static int snd_pcm_hw_clear_timer_queue(snd_pcm_hw_t *hw)
{
if (hw->period_timer_need_poll) {
@@ -542,7 +556,7 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
static snd_pcm_state_t snd_pcm_hw_state(snd_pcm_t *pcm)
{
snd_pcm_hw_t *hw = pcm->private_data;
- int err = sync_ptr(hw, 0);
+ int err = query_state(hw);
if (err < 0)
return err;
return (snd_pcm_state_t) hw->mmap_status->state;
When failing to map status data, applications can query status of runtime of PCM substream by executing ioctl(2) with SNDRV_PCM_IOCTL_SYNC_PTR. This operation is available for several purposes; e.g. to update control data in kernel space. When querying status, the applications don't need to update control data in kernel space. This commit adds a helper function to query status/control data without issuing the control just in fallback from failure of status mmap. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> --- src/pcm/pcm_hw.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)