Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 926853 Details for
Bug 1127097
wrongly searching for device id in audio test
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
audio.py
audio.py (text/plain), 6.53 KB, created by
Guangze Bai
on 2014-08-14 15:36:15 UTC
(
hide
)
Description:
audio.py
Filename:
MIME Type:
Creator:
Guangze Bai
Created:
2014-08-14 15:36:15 UTC
Size:
6.53 KB
patch
obsolete
>#!/usr/bin/python ># Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material ># is made available to anyone wishing to use, modify, copy, or ># redistribute it subject to the terms and conditions of the GNU General ># Public License v.2. ># ># This program is distributed in the hope that it will be useful, but WITHOUT ANY ># WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A ># PARTICULAR PURPOSE. See the GNU General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with this program; if not, write to the Free Software ># Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ># ># Author: Greg Nichols >import os, sys, string, shutil, time, glob, re > >from hwcert.test import Test >from hwcert.tags import Constants, DeviceClass >from hwcert.udevDeviceDetector import UdevDeviceDetector >from hwcert.command import Command > >class AudioTest(Test): > > def __init__(self): > Test.__init__(self, name="audio") > self.deviceClass = DeviceClass.audio > self.cardNumber = 0 > self.captureSupport = False > > def plan(self, planner): > properties = dict() > properties['SUBSYSTEM'] = 'sound' > properties['SOUND_INITIALIZED'] = '1' > properties['ID_BUS'] = 'pci' > tests = self.planWith(planner.getUdevDeviceDetector(), properties, strict=True) > return tests > > def getRequiredRPMs(self): > return ["alsa-utils"] > > def logSoundCardInfo(self): > if self.udi: > self.device = UdevDeviceDetector().getDevice(self.udi) > if self.device: > print "\nSound Card:" > print self.device.dump() > self.cardNumber = self.udi[self.udi.rfind('/')+5:] > for infopath in glob.glob("/proc/asound/card%s/pcm*/info" % self.cardNumber): > print infopath > Command("cat %s" % infopath).echo() > print "" > self.getDeviceNumber() > return True > # otherwise > return False > > def getDeviceNumber(self): > self.deviceNumber = -1 > numidPattern = re.compile("numid=(?P<id>[0-9]+)") > pcmPattern = re.compile("pcm=(?P<id>[0-9]+)") > pipe = os.popen("amixer -c %s controls" % self.cardNumber) > for line in pipe.readlines(): > if "Capture" in line: > self.captureSupport = True > if 'HDMI/DP,pcm=' in line: > match = numidPattern.search(line) > if match: > id = match.group("id") > match = pcmPattern.search(line) > if match: > pcm = match.group("id") > checkStatusCommand = Command("amixer -c %s cget numid=%s" %(self.cardNumber, id)) > try: > if checkStatusCommand.getString("values=on", singleLine=False): > if self.debug != Constants.off: > print "device numid = %s" % id > print "device pcm = %s" % pcm > self.deviceNumber = pcm > break > except Exception, e: > if self.debug != Constants.off: > print "Exception searching for device id:" > print e > > > def run(self): > FAILED = 1 > PASSED = 0 > > if not self.logSoundCardInfo(): > print "Error: could not log sound card information" > return FAILED > > if self.getMode() == Constants.auto: > print("Error: Test Mode: %s: The audio test can not be run in auto mode since audio functions must be verified by the tester." % self.getMode()) > return FAILED > > # otherwise > print "This test plays a sound sample and records it to another file." > print "Please use the Volume Control application and insure that the " > print "Capture settings will record the sound." > if not self.promptConfirm("Continue?"): > self.result = Constants.FAIL > return FAILED > > > if self.captureSupport: > waveFileDuration = 8 # sec. total > recordedWaveFile="./test.wav" > print "starting recording while playing demo sound" > if os.system("arecord -r 44100 -d %s -D plughw:%s %s &" % (waveFileDuration, self.cardNumber, recordedWaveFile)) != 0: > print "Error: arecord command failed" > self.result = Constants.FAIL > return FAILED > else: > print "Note: No Capture Support" > > waveFiles=["/usr/share/sounds/alsa/Front_Right.wav", > "/usr/share/sounds/alsa/Front_Left.wav"] > for waveFile in waveFiles: > if os.path.exists(waveFile): > playCommand = "aplay %s -D plughw:%s" % (waveFile, self.cardNumber) > if self.deviceNumber >= 0: > playCommand = "aplay %s -D plughw:%s,%s" % (waveFile, self.cardNumber, self.deviceNumber) > print playCommand > if os.system(playCommand) != 0: > print "Error: aplay command failed" > self.result = Constants.FAIL > return FAILED > time.sleep(1) > sys.stdout.flush() > if not self.promptConfirm("Did you hear the played sound?"): > self.result = Constants.FAIL > return FAILED > > if self.captureSupport: > print "playing recorded sound" > playCommand = "aplay %s -D plughw:%s" % (recordedWaveFile, self.cardNumber) > if self.deviceNumber >= 0: > playCommand = "aplay %s -D plug:hdmi:%s,%s" % (recordedWaveFile, self.cardNumber, self.deviceNumber) > print playCommand > if os.system(playCommand) != 0: > print "Error: aplay command failed" > self.result = Constants.FAIL > return FAILED > > if not self.promptConfirm("Did you hear the recorded sound?"): > self.result = Constants.FAIL > return FAILED > > outputDirectory = os.path.dirname(self.outputFile) > shutil.copy(recordedWaveFile, outputDirectory) > print "Copied recorded sound %s to %s" % (recordedWaveFile, outputDirectory) > > self.result = Constants.PASS > return PASSED > >if __name__ == "__main__": > test = AudioTest() > returnValue = test.do(sys.argv) > sys.exit(returnValue)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1127097
: 926853