mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-06 00:36:32 +08:00
soundd/micd: increase stream buffer size (#30685)
* increase buffer * update cpu refs * go to 100ms * correct spot old-commit-hash: b0831fb117dde77334b6355975011611afc5d76f
This commit is contained in:
@@ -46,13 +46,13 @@ PROCS = {
|
||||
"selfdrive.thermald.thermald": 3.87,
|
||||
"selfdrive.locationd.calibrationd": 2.0,
|
||||
"selfdrive.locationd.torqued": 5.0,
|
||||
"selfdrive.ui.soundd": 5.8,
|
||||
"selfdrive.ui.soundd": 3.5,
|
||||
"selfdrive.monitoring.dmonitoringd": 4.0,
|
||||
"./proclogd": 1.54,
|
||||
"system.logmessaged": 0.2,
|
||||
"selfdrive.tombstoned": 0,
|
||||
"./logcatd": 0,
|
||||
"system.micd": 10.0,
|
||||
"system.micd": 6.0,
|
||||
"system.timezoned": 0,
|
||||
"selfdrive.boardd.pandad": 0,
|
||||
"selfdrive.statsd": 0.4,
|
||||
|
||||
@@ -16,6 +16,7 @@ from openpilot.common.realtime import Ratekeeper
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
|
||||
SAMPLE_RATE = 48000
|
||||
SAMPLE_BUFFER = 4096 # (approx 100ms)
|
||||
MAX_VOLUME = 1.0
|
||||
MIN_VOLUME = 0.1
|
||||
CONTROLS_TIMEOUT = 5 # 5 seconds
|
||||
@@ -133,11 +134,11 @@ class Soundd:
|
||||
if TICI:
|
||||
micd.wait_for_devices(sd) # wait for alsa to be initialized on device
|
||||
|
||||
with sd.OutputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback) as stream:
|
||||
with sd.OutputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback, blocksize=SAMPLE_BUFFER) as stream:
|
||||
rk = Ratekeeper(20)
|
||||
sm = messaging.SubMaster(['controlsState', 'microphone'])
|
||||
|
||||
cloudlog.info(f"soundd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}")
|
||||
cloudlog.info(f"soundd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}, {stream.blocksize=}")
|
||||
while True:
|
||||
sm.update(0)
|
||||
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@ RATE = 10
|
||||
FFT_SAMPLES = 4096
|
||||
REFERENCE_SPL = 2e-5 # newtons/m^2
|
||||
SAMPLE_RATE = 44100
|
||||
SAMPLE_BUFFER = 4096 # (approx 100ms)
|
||||
|
||||
|
||||
@retry(attempts=7, delay=3)
|
||||
@@ -98,8 +99,8 @@ class Mic:
|
||||
if TICI:
|
||||
wait_for_devices(sd) # wait for alsa to be initialized on device
|
||||
|
||||
with sd.InputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback) as stream:
|
||||
cloudlog.info(f"micd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}")
|
||||
with sd.InputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback, blocksize=SAMPLE_BUFFER) as stream:
|
||||
cloudlog.info(f"micd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}, {stream.blocksize=}")
|
||||
while True:
|
||||
self.update()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user