[alsa-devel] [PATCH alsa-lib 05/12] pcm: hw: use helper function to query status/control data after PREPARE/RESET call

Takashi Sakamoto o-takashi at sakamocchi.jp
Fri Jun 30 01:58:21 CEST 2017


In ALSA PCM core, calls of ioctl(2) with SNDRV_PCM_IOCTL_PREPARE and
SNDRV_PCM_IOCTL_RESET have effects to initialize appl_ptr to current
hw_ptr and shift state of runtime. On the other hand, avail_min of the
runtime is kept as is.

In a fallback mode of status data mapping, after executing the call,
applications should execute ioctl(2) with SNDRV_PCM_IOCTL_SYNC_PTR to
query appl_ptr and the state, while don't need to issue avail_min.

This commit applies a minor optimization to the call.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 src/pcm/pcm_hw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index aa548529..6f20cbff 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -615,7 +615,7 @@ static int snd_pcm_hw_prepare(snd_pcm_t *pcm)
 		SYSMSG("SNDRV_PCM_IOCTL_PREPARE failed (%i)", err);
 		return err;
 	}
-	return sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
+	return query_state(hw);
 }
 
 static int snd_pcm_hw_reset(snd_pcm_t *pcm)
@@ -627,7 +627,7 @@ static int snd_pcm_hw_reset(snd_pcm_t *pcm)
 		SYSMSG("SNDRV_PCM_IOCTL_RESET failed (%i)", err);
 		return err;
 	}
-	return sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
+	return query_state(hw);
 }
 
 static int snd_pcm_hw_start(snd_pcm_t *pcm)
-- 
2.11.0



More information about the Alsa-devel mailing list