def start_play_audio(self, dev):
stdout = open(os.path.join(self.driver.log.logger.report_path, "subprocess_master_stdout.txt"), "w")
stderr = open(os.path.join(self.driver.log.logger.report_path, "subprocess_master_stderr.txt"), "w")
self.play_flag = 0
self.driver.log.info("[Common]Master board start play music.")
self.process_play = subprocess.Popen(
["adb", "-s", dev, "shell",
"alsa_aplay -vv -Dplug:avb:eavb_media /sdcard/PCM_12khz_stereo_384kbps_16bits_60s-wav.wav"],
stdout=stdout.fileno(), stderr=stderr.fileno())
out, err = self.process_play.communicate()
self.driver.log.info("[Common]Play audio file info for :{0} : {1}.".format(out, err))
if self.process_play.returncode != 0:
self.driver.log.error("[Common]Master play failed")
self.play_flag = -1
try:
self.driver.device.shell_cmd("mkdir /sdcard/eavb_log_master.txt -p")
self.driver.device.shell_cmd(
"strace -o /sdcard/eavb_log_master.txt -f audio_system_setparameters is_eavb_stream=false")
time.sleep(10)
self.driver.device.command(
"pull /sdcard/eavb_log_master.txt {0}".format(self.driver.log.logger.report_path))
if self.process_play.pid is None:
self.driver.log.info("[Common]Play pid finished.")
pass
else:
self.driver.log.info("[Common]Kill play pid.")
os.kill(self.process_play.pid, signal.SIGTERM)
except Exception as e:
self.driver.log.warning("[Common]Get master log or kill play process exception :{}".format(str(e)))
finally:
stdout.flush()
stderr.flush()
stdout.close()
stderr.close()