Commit 0825d54a authored by Nícolas F. R. A. Prado's avatar Nícolas F. R. A. Prado Committed by Takashi Iwai

kselftest/alsa: pcm-test: Move stream duration and margin to variables

The duration to stream for and time margin to consider the stream failed
are currently hardcoded values. Move them to variables so they can be
reused and more easily changed.
Signed-off-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230620220839.2215057-2-nfraprado@collabora.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 35bc3efb
...@@ -258,6 +258,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, ...@@ -258,6 +258,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,
const char *test_name, snd_config_t *pcm_cfg) const char *test_name, snd_config_t *pcm_cfg)
{ {
char name[64], key[128], msg[256]; char name[64], key[128], msg[256];
const int duration_s = 4, margin_ms = 100;
const int duration_ms = duration_s * 1000;
const char *cs; const char *cs;
int i, err; int i, err;
snd_pcm_t *handle = NULL; snd_pcm_t *handle = NULL;
...@@ -442,7 +444,7 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, ...@@ -442,7 +444,7 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,
skip = false; skip = false;
timestamp_now(&tstamp); timestamp_now(&tstamp);
for (i = 0; i < 4; i++) { for (i = 0; i < duration_s; i++) {
if (data->stream == SND_PCM_STREAM_PLAYBACK) { if (data->stream == SND_PCM_STREAM_PLAYBACK) {
frames = snd_pcm_writei(handle, samples, rate); frames = snd_pcm_writei(handle, samples, rate);
if (frames < 0) { if (frames < 0) {
...@@ -472,8 +474,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, ...@@ -472,8 +474,8 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class,
snd_pcm_drain(handle); snd_pcm_drain(handle);
ms = timestamp_diff_ms(&tstamp); ms = timestamp_diff_ms(&tstamp);
if (ms < 3900 || ms > 4100) { if (ms < duration_ms - margin_ms || ms > duration_ms + margin_ms) {
snprintf(msg, sizeof(msg), "time mismatch: expected 4000ms got %lld", ms); snprintf(msg, sizeof(msg), "time mismatch: expected %dms got %lld", duration_ms, ms);
goto __close; goto __close;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment