public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Martin Peres <martin.peres@linux.intel.com>
To: Simon Ser <simon.ser@intel.com>, igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v2 2/9] tests/kms_chamelium: introduce audio_state_receive
Date: Mon, 27 May 2019 15:24:27 +0300	[thread overview]
Message-ID: <2e82e5e5-a7f8-d25b-a975-c79ee7cfcb43@linux.intel.com> (raw)
In-Reply-To: <20190524150334.15833-3-simon.ser@intel.com>

On 24/05/2019 18:03, Simon Ser wrote:
> This extracts the logic receiving audio pages in do_test_display_audio into a
> new audio_state_receive function. The function takes care of updating the
> current msec counter and dumping the received data in a file.

Reviewed-by: Martin Peres <martin.peres@linux.intel.com>

> 
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
>  tests/kms_chamelium.c | 55 ++++++++++++++++++++++++++++---------------
>  1 file changed, 36 insertions(+), 19 deletions(-)
> 
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 1a0a02ca2890..6fdb9d68fcf2 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -827,6 +827,9 @@ struct audio_state {
>  	struct audio_signal *signal;
>  	int channel_mapping[8];
>  
> +	size_t recv_pages;
> +	int msec;
> +
>  	int dump_fd;
>  	char *dump_path;
>  
> @@ -876,6 +879,9 @@ static void audio_state_start(struct audio_state *state)
>  	enum chamelium_stream_realtime_mode stream_mode;
>  	char dump_suffix[64];
>  
> +	state->recv_pages = 0;
> +	state->msec = 0;
> +
>  	igt_debug("Starting test with playback format %s, sampling rate %d Hz "
>  		  "and %d channels\n",
>  		  snd_pcm_format_name(state->playback.format),
> @@ -936,6 +942,29 @@ static void audio_state_start(struct audio_state *state)
>  	}
>  }
>  
> +static void audio_state_receive(struct audio_state *state,
> +				int32_t **recv, size_t *recv_len)
> +{
> +	bool ok;
> +	size_t page_count;
> +	size_t recv_size;
> +
> +	ok = chamelium_stream_receive_realtime_audio(state->stream,
> +						     &page_count,
> +						     recv, recv_len);
> +	igt_assert(ok);
> +
> +	state->msec = state->recv_pages * *recv_len
> +		      / (double) state->capture.channels
> +		      / (double) state->capture.rate * 1000;
> +	state->recv_pages++;
> +
> +	if (state->dump_fd >= 0) {
> +		recv_size = *recv_len * sizeof(int32_t);
> +		igt_assert(write(state->dump_fd, *recv, recv_size) == recv_size);
> +	}
> +}
> +
>  static void audio_state_stop(struct audio_state *state, bool success)
>  {
>  	bool ok;
> @@ -1003,12 +1032,12 @@ audio_output_callback(void *data, void *buffer, int samples)
>  
>  static bool do_test_display_audio(struct audio_state *state)
>  {
> -	int msec, freq, step;
> +	int freq, step;
>  	int32_t *recv, *buf;
>  	double *channel;
> -	size_t i, j, streak, page_count;
> -	size_t recv_len, buf_len, buf_cap, buf_size, channel_len;
> -	bool ok, success;
> +	size_t i, j, streak;
> +	size_t recv_len, buf_len, buf_cap, channel_len;
> +	bool success;
>  	int capture_chan;
>  
>  	state->signal = audio_signal_init(state->playback.channels,
> @@ -1064,13 +1093,8 @@ static bool do_test_display_audio(struct audio_state *state)
>  
>  	success = false;
>  	streak = 0;
> -	msec = 0;
> -	i = 0;
> -	while (!success && msec < AUDIO_TIMEOUT) {
> -		ok = chamelium_stream_receive_realtime_audio(state->stream,
> -							     &page_count,
> -							     &recv, &recv_len);
> -		igt_assert(ok);
> +	while (!success && state->msec < AUDIO_TIMEOUT) {
> +		audio_state_receive(state, &recv, &recv_len);
>  
>  		memcpy(&buf[buf_len], recv, recv_len * sizeof(int32_t));
>  		buf_len += recv_len;
> @@ -1079,13 +1103,7 @@ static bool do_test_display_audio(struct audio_state *state)
>  			continue;
>  		igt_assert(buf_len == buf_cap);
>  
> -		if (state->dump_fd >= 0) {
> -			buf_size = buf_len * sizeof(int32_t);
> -			igt_assert(write(state->dump_fd, buf, buf_size) == buf_size);
> -		}
> -
> -		msec = i * channel_len / (double) state->capture.rate * 1000;
> -		igt_debug("Detecting audio signal, t=%d msec\n", msec);
> +		igt_debug("Detecting audio signal, t=%d msec\n", state->msec);
>  
>  		for (j = 0; j < state->playback.channels; j++) {
>  			capture_chan = state->channel_mapping[j];
> @@ -1107,7 +1125,6 @@ static bool do_test_display_audio(struct audio_state *state)
>  		}
>  
>  		buf_len = 0;
> -		i++;
>  
>  		success = streak == MIN_STREAK * state->playback.channels;
>  	}
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-05-27 12:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 15:03 [igt-dev] [PATCH i-g-t v2 0/9] tests/kms_chamelium: add pulse test Simon Ser
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 1/9] tests/kms_chamelium: refactor audio test Simon Ser
2019-05-27 10:20   ` Martin Peres
2019-05-27 12:17     ` Ser, Simon
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 2/9] tests/kms_chamelium: introduce audio_state_receive Simon Ser
2019-05-27 12:24   ` Martin Peres [this message]
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 3/9] tests/kms_chamelium: rename do_test_display_audio and test_audio_configuration Simon Ser
2019-05-27 12:25   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 4/9] tests/kms_chamelium: explain why 8-channel tests aren't performed Simon Ser
2019-05-27 12:25   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 5/9] lib/igt_audio: introduce audio_convert_to Simon Ser
2019-05-27 12:27   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 6/9] tests/kms_chamelium: add name parameter to audio_state_start Simon Ser
2019-05-27 12:29   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 7/9] lib/igt_audio: make audio_extract_channel_s32_le support a NULL dst Simon Ser
2019-05-27 12:30   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 8/9] tests/kms_chamelium: add pulse audio test Simon Ser
2019-05-27 12:46   ` Martin Peres
2019-05-24 15:03 ` [igt-dev] [PATCH i-g-t v2 9/9] tests/kms_chamelium: add audio channel alignment test Simon Ser
2019-05-27 13:34   ` Martin Peres
2019-05-26  9:58 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_chamelium: add pulse test Patchwork
2019-05-26 13:09 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-05-27  6:31   ` Ser, Simon
2019-05-27 13:41     ` Martin Peres
2019-05-27  7:01 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_chamelium: add pulse test (rev2) Patchwork
2019-05-27 15:00 ` [igt-dev] ✓ Fi.CI.IGT: " 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=2e82e5e5-a7f8-d25b-a975-c79ee7cfcb43@linux.intel.com \
    --to=martin.peres@linux.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