From 16859211f576cd9d95ff319916047837ee16a93c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 2 Dec 2022 15:25:34 -0800 Subject: [PATCH] micd: revert check playing sound (high cpu usage) (#26672) * don't use hardware * check micd proc * use pactl package * cleanup * Revert "cleanup" This reverts commit baf9887e2d3e7dce8c24a93e970bb5a2d3609d50. * Revert "use pactl package" This reverts commit 0c1f3a4b865e44052affa57323ae4a21d274d6e3. * Revert "micd: don't update filtered sound level if playing sound (#26652)" This reverts commit 6703f6fa0297ad587ce80fcf1af432c402ba4e7e. * Revert "check micd proc" This reverts commit 9ebbe2aa42bdfd2f7f8bf226978a518d984fb154. Co-authored-by: Cameron Clough old-commit-hash: 060b69ee2f5148140ec696cbc950b83f700fd671 --- system/hardware/base.py | 4 ---- system/hardware/pc/hardware.py | 4 ---- system/hardware/tici/hardware.py | 3 --- system/micd.py | 4 +--- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/system/hardware/base.py b/system/hardware/base.py index 16ed9621c1..31df1babe0 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -43,10 +43,6 @@ class HardwareBase(ABC): def get_sound_card_online(self): pass - @abstractmethod - def is_sound_playing(self): - pass - @abstractmethod def get_imei(self, slot) -> str: pass diff --git a/system/hardware/pc/hardware.py b/system/hardware/pc/hardware.py index 2c83eb35f4..564f9e483a 100644 --- a/system/hardware/pc/hardware.py +++ b/system/hardware/pc/hardware.py @@ -1,5 +1,4 @@ import random -import subprocess from cereal import log from system.hardware.base import HardwareBase, ThermalConfig @@ -18,9 +17,6 @@ class Pc(HardwareBase): def get_sound_card_online(self): return True - def is_sound_playing(self): - return "RUNNING" in subprocess.check_output(["pactl", "list", "short", "sinks"]).decode('utf8') - def reboot(self, reason=None): print("REBOOT!") diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index 8371d6ef70..b5f5e00410 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -96,9 +96,6 @@ class Tici(HardwareBase): return (os.path.isfile('/proc/asound/card0/state') and open('/proc/asound/card0/state').read().strip() == 'ONLINE') - def is_sound_playing(self): - return "RUNNING" in subprocess.check_output(["pactl", "list", "short", "sinks"]).decode('utf8') - def reboot(self, reason=None): subprocess.check_output(["sudo", "reboot"]) diff --git a/system/micd.py b/system/micd.py index 57700e5927..d0c661ee0d 100755 --- a/system/micd.py +++ b/system/micd.py @@ -5,7 +5,6 @@ import numpy as np from cereal import messaging from common.filter_simple import FirstOrderFilter from common.realtime import Ratekeeper -from system.hardware import HARDWARE from system.swaglog import cloudlog RATE = 10 @@ -60,8 +59,7 @@ class Mic: sound_pressure, _ = calculate_spl(self.measurements) measurements_weighted = apply_a_weighting(self.measurements) sound_pressure_weighted, sound_pressure_level_weighted = calculate_spl(measurements_weighted) - if not HARDWARE.is_sound_playing(): - self.spl_filter_weighted.update(sound_pressure_level_weighted) + self.spl_filter_weighted.update(sound_pressure_level_weighted) else: sound_pressure = 0 sound_pressure_weighted = 0