From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/8] tests/kms_chamelium: introduce audio_state_receive
Date: Fri, 24 May 2019 11:07:30 +0300 [thread overview]
Message-ID: <20190524080736.9173-3-simon.ser@intel.com> (raw)
In-Reply-To: <20190524080736.9173-1-simon.ser@intel.com>
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.
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 1fb4df3020d6..3a78aa150bef 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;
@@ -997,12 +1026,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,
@@ -1058,13 +1087,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;
@@ -1073,13 +1097,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];
@@ -1101,7 +1119,6 @@ static bool do_test_display_audio(struct audio_state *state)
}
buf_len = 0;
- i++;
success = streak == MIN_STREAK * state->playback.channels;
}
--
2.21.0
_______________________________________________
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-24 8:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 8:07 [igt-dev] [PATCH i-g-t 0/8] tests/kms_chamelium: add amplitude test Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 1/8] tests/kms_chamelium: refactor audio test Simon Ser
2019-05-24 8:07 ` Simon Ser [this message]
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 3/8] tests/kms_chamelium: rename do_test_display_audio and test_audio_configuration Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 4/8] tests/kms_chamelium: explain why 8-channel tests aren't performed Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 5/8] lib/igt_audio: introduce audio_convert_to Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 6/8] tests/kms_chamelium: add name parameter to audio_state_start Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 7/8] lib/igt_audio: make audio_extract_channel_s32_le support a NULL dst Simon Ser
2019-05-24 8:07 ` [igt-dev] [PATCH i-g-t 8/8] tests/kms_chamelium: add pulse audio test Simon Ser
2019-05-24 10:41 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/kms_chamelium: add amplitude test 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=20190524080736.9173-3-simon.ser@intel.com \
--to=simon.ser@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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