Skip to content

Commit 9b67935

Browse files
committed
tools: wov_capture: handle EPIPE recover and retry active slot query
- In wov_blocking_read, recover from -EPIPE on no-period-wakeup streams and retry active slot kcontrol query to ensure robust slot matching upon receiving audio. - In run_wov_10x.py, report subprogram stdout and stderr on test failure to aid rapid diagnosis. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent b020d0d commit 9b67935

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎tools/wov_capture/run_wov_10x.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def run_s0_iteration(iteration, slot, ctl, card=0, device=None):
164164
"post_slot": post_slot,
165165
"post_ctl": post_ctl,
166166
"continuity": continuity_msg,
167+
"stdout": p.stdout,
168+
"stderr": p.stderr,
167169
"passed": passed,
168170
}
169171

@@ -256,6 +258,11 @@ def main():
256258
s0_results.append(res)
257259
status_str = "PASS" if res["passed"] else "FAIL"
258260
print(f" [S0 Run {i:02d}/10] Slot {slot} ({ctl}): {status_str} in {res['elapsed']:.2f}s, trig_slot={res['trig_slot']}, size={res['size']}B, continuity=[{res['continuity']}], slot_reset={res['post_slot']}, ctl_reset={res['post_ctl']}")
261+
if not res["passed"]:
262+
if res.get("stderr"):
263+
print(f" STDERR: {res['stderr'].strip()}")
264+
if res.get("stdout"):
265+
print(f" STDOUT: {res['stdout'].strip()}")
259266
sys.stdout.flush()
260267
time.sleep(3.0)
261268

‎tools/wov_capture/wov_blocking_read.c‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int get_active_slot(int card)
4848
snd_ctl_elem_value_set_id(val, id);
4949

5050
int slot = -1;
51-
for (int retry = 0; retry < 15; retry++) {
51+
for (int retry = 0; retry < 30; retry++) {
5252
if (snd_ctl_elem_read(ctl_handle, val) >= 0) {
5353
slot = snd_ctl_elem_value_get_enumerated(val, 0);
5454
if (slot > 0)
@@ -198,22 +198,32 @@ int main(int argc, char **argv)
198198
}
199199
continue;
200200
}
201+
if (n == -EPIPE) {
202+
snd_pcm_recover(pcm, n, 0);
203+
continue;
204+
}
201205
fprintf(stderr, "read error: %s\n", snd_strerror((int)n));
202206
break;
203207
}
204208
if (n > 0) {
205-
if (triggered_slot < 0) {
206-
triggered_slot = get_active_slot(card);
207-
printf("t=%.3f triggered active_slot=%d (expected=%d)\n",
208-
now_s() - t0, triggered_slot, expected_slot);
209-
fflush(stdout);
210-
}
211209
if (wav_fp)
212210
fwrite(buf, sizeof(short), n, wav_fp);
213211
frames_captured += n;
214212
}
215213
}
216214

215+
for (int retry = 0; retry < 25; retry++) {
216+
int s = get_active_slot(card);
217+
if (s > 0) {
218+
triggered_slot = s;
219+
break;
220+
}
221+
usleep(20000);
222+
}
223+
printf("t=%.3f triggered active_slot=%d (expected=%d)\n",
224+
now_s() - t0, triggered_slot > 0 ? triggered_slot : 0, expected_slot);
225+
fflush(stdout);
226+
217227
double t1 = now_s();
218228
printf("t=%.3f capture finished: %u frames after %.3fs\n", t1 - t0, frames_captured, t1 - t0);
219229

0 commit comments

Comments
 (0)