[v1,4/4] alsabat: XRUN injections test criteria
diff mbox

Message ID 20170831133709.25537-5-keqiao.zhang@intel.com
State New
Headers show

Commit Message

keqiao.zhang@intel.com Aug. 31, 2017, 1:37 p.m. UTC
Check if target number of frames can be detected after XRUNs.

Signed-off-by: Zhang Keqiao <keqiao.zhang@intel.com>
---
 bat/analyze.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Patch
diff mbox

diff --git a/bat/analyze.c b/bat/analyze.c
index 17fff50..1c48a6b 100644
--- a/bat/analyze.c
+++ b/bat/analyze.c
@@ -471,9 +471,25 @@  int analyze_capture(struct bat *bat)
 		goto exit2;
 
 	items = fread(bat->buf, bat->frame_size, bat->frames, bat->fp);
-	if (items != bat->frames) {
-		err = -EIO;
-		goto exit2;
+
+	/* check the number of frames recorded after XRUNs */
+	if (bat->xarg) {
+		if (items != bat->frames) {
+			fprintf(bat->err, _("\nXRUN injection test FAILED\n"));
+			fprintf(bat->err, _("Target frames number %d, actually got %zu\n"),
+				bat->frames, items);
+			err = -EIO;
+			goto exit2;
+		} else {
+			fprintf(bat->log, _("\nXRUN injection test PASSED\n"));
+			err = 0; /* target frames can be detected after XRUNs */
+			goto exit2;
+		}
+	} else {
+		if (items != bat->frames) {
+			err = -EIO;
+			goto exit2;
+		}
 	}
 
 	err = reorder_data(bat);