diff mbox

[RFC,12/21] ALSA: pcm: add tracepoints for selection process of hardware parameters at SNDRV_PCM_IOCTL_HW_PARAMS

Message ID 20170514085756.22382-13-o-takashi@sakamocchi.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Sakamoto May 14, 2017, 8:57 a.m. UTC
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@sakamocchi.jp>
---
 sound/core/pcm_native.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox

Patch

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;
 	}