[alsa-devel] [PATCH RFC 12/21] ALSA: pcm: add tracepoints for selection process of hardware parameters at SNDRV_PCM_IOCTL_HW_PARAMS

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun May 14 10:57:47 CEST 2017


Results of ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE and
SNDRV_PCM_IOCTL_HW_PARAMS are different, because the latter has single
value for several parameters; e.g. channels of PCM substream. Selection
of the single value is done independently of application of constraints
and rules. It's helpful for developers to trace the selection process

This commit adds tracepoints to snd_pcm_hw_params_choose() for the
purpose.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 sound/core/pcm_native.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 2c5a4d9..47af1a8 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -555,11 +555,35 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm,
 	const int *v;
 	int err;
 
+	struct snd_interval __maybe_unused old_interval;
+	struct snd_mask __maybe_unused old_mask;
+
 	for (v = vars; *v != -1; v++) {
+		/* Keep old parameter to trace. */
+		if (trace_hw_params_mask_enabled()) {
+			if (hw_is_mask(*v))
+				old_mask = *hw_param_mask(params, *v);
+		}
+		if (trace_hw_params_interval_enabled()) {
+			if (hw_is_interval(*v))
+				old_interval = *hw_param_interval(params, *v);
+		}
+
 		if (*v != SNDRV_PCM_HW_PARAM_BUFFER_SIZE)
 			err = snd_pcm_hw_param_first(pcm, params, *v, NULL);
 		else
 			err = snd_pcm_hw_param_last(pcm, params, *v, NULL);
+
+		/* Trace the parameter. */
+		if (hw_is_mask(*v)) {
+			trace_hw_params_mask(pcm, *v, -1, &old_mask,
+					     hw_param_mask(params, *v));
+		}
+		if (hw_is_interval(*v)) {
+			trace_hw_params_interval(pcm, *v, -1, &old_interval,
+						 hw_param_interval(params, *v));
+		}
+
 		if (snd_BUG_ON(err < 0))
 			return err;
 	}
-- 
2.9.3



More information about the Alsa-devel mailing list