[autotest] audio_facade: fix stop_playback()
In the original stop_playback(), it doesn't really terminate the cras
command when it terminates the multiprocessing process.
BUG=None
TEST=manual test
Modify audio_AudioVolume to stop_playback() before stop_capturing(),
and verify the captured audio is not completed.
Change-Id: I6a30c78e49f5a9ffd3f46a95e2b241492b68f353
Reviewed-on: https://chromium-review.googlesource.com/374279
Commit-Ready: Chen-hao Chang <haocc@google.com>
Tested-by: Chen-hao Chang <haocc@google.com>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/client/cros/audio/cras_utils.py b/client/cros/audio/cras_utils.py
index b8cec0c..26301fb 100644
--- a/client/cros/audio/cras_utils.py
+++ b/client/cros/audio/cras_utils.py
@@ -16,14 +16,20 @@
pass
-def playback(*args, **kargs):
+def playback(blocking=True, *args, **kargs):
"""A helper function to execute the playback_cmd.
+ @param blocking: Blocks this call until playback finishes.
@param args: args passed to playback_cmd.
@param kargs: kargs passed to playback_cmd.
+ @returns: The process running the playback command. Note that if the
+ blocking parameter is true, this will return a finished process.
"""
- cmd_utils.execute(playback_cmd(*args, **kargs))
+ process = cmd_utils.popen(playback_cmd(*args, **kargs))
+ if blocking:
+ cmd_utils.wait_and_check_returncode(process)
+ return process
def capture(*args, **kargs):