Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: client/site_tests/audiovideo_Microphone/audiovideo_Microphone.py

Issue 6853017: Microphone test using alsa instead of pulsaaudio command. (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os, time 5 import os, time, utils
6 6
7 from autotest_lib.client.bin import test, utils 7 from autotest_lib.client.bin import test, utils
8 from autotest_lib.client.common_lib import error 8 from autotest_lib.client.common_lib import error
9 9
10 DURATION = 30 10 DURATION = 30
11 BYTES_PER_SAMPLE = 2 11 BYTES_PER_SAMPLE = 2
12 TOLERATE = 0.8 12 TOLERATE = 0.8
13 13
14 class audiovideo_Microphone(test.test): 14 class audiovideo_Microphone(test.test):
15 version = 1 15 version = 1
16 16
17 def verify_capture(self, ch, rate): 17 def verify_capture(self, ch, rate):
18 file_name = "/tmp/%s-%s.capture" % (ch, rate) 18 file_name = "/tmp/%s-%s.capture" % (ch, rate)
19 cmd = "rm -f %s" % file_name 19 cmd = "rm -f %s" % file_name
20 utils.system(cmd, ignore_status=True) 20 utils.system(cmd, ignore_status=True)
21 cmd = "/usr/bin/pkill pacat" 21 cmd = "arecord -f dat -D default -c %s -r %s -d %d %s"
22 utils.system(cmd, ignore_status=True) 22 cmd = cmd % (ch, rate, DURATION, file_name)
23 cmd = "pacat -r --channels=%s --rate=%s %s &" % (ch, rate, file_name)
24 utils.system(cmd)
25 time.sleep(DURATION)
26 cmd = "/usr/bin/pkill pacat"
27 utils.system(cmd) 23 utils.system(cmd)
28 size = os.path.getsize(file_name) 24 size = os.path.getsize(file_name)
29 if (size < DURATION * rate * ch * BYTES_PER_SAMPLE * TOLERATE) : 25 if (size < DURATION * rate * ch * BYTES_PER_SAMPLE * TOLERATE) :
30 raise error.TestFail("File size not correct: %s" % file_name) 26 raise error.TestFail("File size not correct: %s" % file_name)
31 utils.system("rm -f %s" % file_name) 27 utils.system("rm -f %s" % file_name)
32 28
33 29
34 def run_once(self): 30 def run_once(self):
31 cpuType = utils.get_cpu_arch()
35 # Microphone should be on by default. 32 # Microphone should be on by default.
36 cmd = 'amixer -c 0 cget name="Capture Switch" | grep values=on,on' 33 if cpuType != "arm":
37 output = utils.system_output(cmd) 34 cmd = 'amixer -c 0 cget name="Capture Switch" | grep values=on,on'
38 if (output == ''): 35 output = utils.system_output(cmd)
39 raise error.TestFail('The microphone is not on by default.') 36 if (output == ''):
37 raise error.TestFail('The microphone is not on by default.')
38 else:
39 # TODO(jiesun): find consistent way to find the ALSA mixer control
40 # names for both internal mic and external mic on ARM, which is
41 # independent of the audio codec hardware vendor.
42 print "Warning: Can not verify the microphone capture switch."
40 43
41 # Mono and stereo capturing should work fine @ 44.1KHz and 48KHz. 44 # Mono and stereo capturing should work fine @ 44.1KHz and 48KHz.
42 self.verify_capture(1, 44100) 45 self.verify_capture(1, 44100)
43 self.verify_capture(1, 48000) 46 self.verify_capture(1, 48000)
47 self.verify_capture(2, 48000)
44 self.verify_capture(2, 44100) 48 self.verify_capture(2, 44100)
45 self.verify_capture(2, 48000)
46 49
47 # TODO(zhurunz): 50 # TODO(zhurunz):
48 # Low latency capturing should work fine with low CPU usage. 51 # Low latency capturing should work fine with low CPU usage.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698