From: Martin Peres <martin.peres@intel.com>
To: Simon Ser <simon.ser@intel.com>, igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 2/2] lib/igt_audio: sanity-check generated signals
Date: Fri, 17 May 2019 15:33:35 +0300 [thread overview]
Message-ID: <68ea0b7f-7720-c0f8-8c6d-f037ee2c3660@intel.com> (raw)
In-Reply-To: <20190517101155.21533-2-simon.ser@intel.com>
On 17/05/2019 13:11, Simon Ser wrote:
> This is a safety net to ensure we haven't completely messed up our signal
> generation. It would be unfortunate to send e.g. a null signal after a
> refactoring.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/igt_audio.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> index f6c8e399e345..0d7422c6f3ec 100644
> --- a/lib/igt_audio.c
> +++ b/lib/igt_audio.c
> @@ -213,6 +213,34 @@ static size_t audio_signal_count_freqs(struct audio_signal *signal, int channel)
> return n;
> }
>
> +/** audio_sanity_check:
> + *
> + * Make sure our generated signal is not messed up. In particular, make sure
> + * the maximum reaches a reasonable value but doesn't exceed our
> + * SYNTHESIZE_AMPLITUDE limit. Same for the minimum.
> + *
> + * We want the signal to be powerful enough to be able to hear something. We
> + * want the signal not to reach 1.0 so that we're sure it won't get capped by
> + * the audio card or the receiver.
> + */
> +static void audio_sanity_check(double *samples, size_t samples_len)
> +{
> + size_t i;
> + double min = 0, max = 0;
> +
> + for (i = 0; i < samples_len; i++) {
> + if (samples[i] < min)
> + min = samples[i];
> + if (samples[i] > max)
> + max = samples[i];
> + }
> +
> + igt_assert(-SYNTHESIZE_AMPLITUDE <= min);
> + igt_assert(min <= -SYNTHESIZE_AMPLITUDE + 0.2);
> + igt_assert(SYNTHESIZE_AMPLITUDE - 0.2 <= max);
> + igt_assert(max <= SYNTHESIZE_AMPLITUDE);
Maybe we should make the 0.2 a MACRO? Anyway, looks good!
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
> +}
> +
> /**
> * audio_signal_fill:
> * @signal: The target signal structure
> @@ -268,6 +296,8 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
> total += count;
> }
> }
> +
> + audio_sanity_check(buffer, signal->channels * samples);
> }
>
> void audio_signal_fill_s16_le(struct audio_signal *signal, int16_t *buffer,
>
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-17 12:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-17 10:11 [igt-dev] [PATCH i-g-t 1/2] lib/igt_audio: fix synthesized signal amplitude Simon Ser
2019-05-17 10:11 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_audio: sanity-check generated signals Simon Ser
2019-05-17 12:33 ` Martin Peres [this message]
2019-05-17 11:04 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/igt_audio: fix synthesized signal amplitude Patchwork
2019-05-17 12:34 ` [igt-dev] [PATCH i-g-t 1/2] " Martin Peres
2019-05-17 14:03 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68ea0b7f-7720-c0f8-8c6d-f037ee2c3660@intel.com \
--to=martin.peres@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=simon.ser@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox