Make audiovideo_CRASFormatConversion not so flaky.
Fix the following issues:
1. Use fixed but different sine tones in the two audio streams at different
sampling rate
2. Set output node volume level to 100
TEST=Run the test on stout and parrot.
BUG=chromium:307378
Change-Id: I36df3522f8b116f142d5147ffe2c71cbf399332d
Reviewed-on: https://chromium-review.googlesource.com/177430
Reviewed-by: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Commit-Queue: Owen Lin <owenlin@chromium.org>
diff --git a/client/cros/audio/audio_helper.py b/client/cros/audio/audio_helper.py
index 7d9d0ad..7305b06 100644
--- a/client/cros/audio/audio_helper.py
+++ b/client/cros/audio/audio_helper.py
@@ -5,6 +5,7 @@
import logging
import os
+import pipes
import re
import shlex
import subprocess
@@ -12,7 +13,6 @@
import time
from glob import glob
-
from autotest_lib.client.bin import utils
from autotest_lib.client.bin.input.input_device import *
from autotest_lib.client.common_lib import error
@@ -484,3 +484,31 @@
# If there is only one soundcard, return it, else return not found (None)
return '0' if id == 1 else None
+
+def execute(args, stdin=None, stdout=None):
+ '''Executes a child command and wait for it.
+
+ Returns the output from standard output if 'stdout' is subprocess.PIPE.
+ Raises RuntimeError if the return code of the child command is not 0.
+
+ @param args: the command to be executed
+ @param stdin: the executed program's standard input
+ @param stdout: the executed program's stdandrd output
+ '''
+
+ ps = popen(args, stdin=stdin, stdout=stdout)
+ out = ps.communicate()[0] if stdout == subprocess.PIPE else None
+ returncode = ps.wait()
+ if returncode != 0:
+ raise RuntimeError( 'command failed(%d): %s' % (returncode, ps.command))
+ return out
+
+def popen(*args, **kargs):
+ '''Returns a Popen object just as subprocess.Popen does but with the
+ executed command stored in Popen.command.
+ '''
+ ps = subprocess.Popen(*args, **kargs)
+ the_args = args[0] if len(args) > 0 else kargs['args']
+ ps.command = ' '.join(pipes.quote(x) for x in the_args)
+ logging.info('Running: %s', ps.command)
+ return ps