Skip to content

Commit

Permalink
micd: revert check playing sound (high cpu usage) (commaai#26672)
Browse files Browse the repository at this point in the history
* don't use hardware

* check micd proc

* use pactl package

* cleanup

* Revert "cleanup"

This reverts commit baf9887.

* Revert "use pactl package"

This reverts commit 0c1f3a4.

* Revert "micd: don't update filtered sound level if playing sound (commaai#26652)"

This reverts commit 86cd919.

* Revert "check micd proc"

This reverts commit 9ebbe2a.

Co-authored-by: Cameron Clough <cameronjclough@gmail.com>
  • Loading branch information
2 people authored and krkeegan committed Jan 4, 2023
1 parent eed42d1 commit 5d58704
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 14 deletions.
4 changes: 0 additions & 4 deletions system/hardware/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def get_device_type(self):
def get_sound_card_online(self):
pass

@abstractmethod
def is_sound_playing(self):
pass

@abstractmethod
def get_imei(self, slot) -> str:
pass
Expand Down
4 changes: 0 additions & 4 deletions system/hardware/pc/hardware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import random
import subprocess

from cereal import log
from system.hardware.base import HardwareBase, ThermalConfig
Expand All @@ -18,9 +17,6 @@ def get_device_type(self):
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!")

Expand Down
3 changes: 0 additions & 3 deletions system/hardware/tici/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ def get_sound_card_online(self):
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"])

Expand Down
4 changes: 1 addition & 3 deletions system/micd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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
Expand Down Expand Up @@ -61,8 +60,7 @@ def update(self):
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
Expand Down

0 comments on commit 5d58704

Please sign in to comment.