CRAS: Skip underrun check for non-normal state device
The bug is related to commit
1212622 CRAS: Call update_dev_wake_time for non-normal device state
For a non-normal state device, the underrun check should be skipped.
Or the underrun operation will fill lots of zeros to device when
starting a new stream.
BUG=chromium:878423
TEST=Open a playback stream for a while and close it.
$ cras_test_client --playback_f /dev/zero
There should not be any underrun event captured by snapshot
$ cras_test_client --dump_e
Change-Id: I786c30d278f0efc58437b9dc27d573460e4d1581
Reviewed-on: https://chromium-review.googlesource.com/1212253
Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
diff --git a/cras/src/server/dev_io.c b/cras/src/server/dev_io.c
index e3931ea..f90a827 100644
--- a/cras/src/server/dev_io.c
+++ b/cras/src/server/dev_io.c
@@ -815,6 +815,13 @@
update_dev_wakeup_time(adev, &hw_level);
/*
+ * Skip the underrun check for non-normal state device.
+ */
+ if (cras_iodev_state(adev->dev) !=
+ CRAS_IODEV_STATE_NORMAL_RUN)
+ continue;
+
+ /*
* If new hardware level is less than or equal to the
* written frames, we can suppose underrun happened. But
* keep in mind there may have a false positive. If