Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/omamobile-audio/lib/speaker_dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ def _load(self):
except (OSError, ValueError):
return {}

def _save(self, state):
# rename over the file, so the fake mixer reading it at the same
# moment never sees half of it
tmp = f'{self.path}.{os.getpid()}'
with open(tmp, 'w') as f:
json.dump(state, f)
os.replace(tmp, self.path)

def names(self):
return list(self._load())

Expand All @@ -238,8 +246,7 @@ def read(self, name):
if name.endswith('HALO_HEARTBEAT') and os.environ.get('FAKE_HB_STUCK') != '1' and not frozen:
v += 1 # the firmware's heartbeat moves while it runs
c['v'] = list(v.to_bytes(4, 'big'))
with open(self.path, 'w') as f:
json.dump(state, f)
self._save(state)
return v
if t == 'ENUMERATED':
return c['items'][c['v']]
Expand Down Expand Up @@ -274,8 +281,7 @@ def write_bytes(self, name, data):
if log_path:
with open(log_path, 'a') as f:
f.write(name + '\n')
with open(self.path, 'w') as f:
json.dump(state, f)
self._save(state)
return True


Expand Down
8 changes: 6 additions & 2 deletions packages/omamobile-audio/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,12 @@ pass "watchdog: mutes on DSP errors, bypass, levels, runtime PM, a stuck heartbe
# level drop, so a jump there must not mute; OMAMOBILE_SPK_TEMP_JUMP brings it back.
jump() { # name [wprep...]: watchdog on a running stream; the bottom's estimate goes 25 -> 40 C a moment in
local n=$1; shift; echo 'state: RUNNING' > "$r/asound/card0/pcm5p/sub0/status"; wprep=("$@")
( sleep 0.4; amx cset "name=Bottom DSP1 Protection cd CSPL_TEMPERATURE" 0x00,0x0a,0x00,0x00 >/dev/null ) &
watchrun; wait
# the jump comes once the watchdog has its first reading (its start line,
# then a few intervals), not at a fixed time: a slow runner started it late
rm -f "$r/watch.out"
( for _ in $(seq 1 100); do grep -c 'watchdog: watching' "$r/watch.out" >/dev/null 2>&1 && break; sleep 0.05; done
sleep 0.3; amx cset "name=Bottom DSP1 Protection cd CSPL_TEMPERATURE" 0x00,0x0a,0x00,0x00 >/dev/null ) &
WATCH_N=60 watchrun; wait
}
startok w-jump8; jump w-jump8
((rc == 0)) && ! muted && grep -c 'jump rule off' "$r/watch.out" >/dev/null || { cat "$r/watch.out" >&2; fail "watchdog: at analog 10 or below a 15 C jump of the estimate does not mute (C9j)"; }
Expand Down
6 changes: 5 additions & 1 deletion packages/omamobile-audio/test/fake-amixer
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def load():


def save(c):
with open(state_path, 'w') as f:
# write and rename, so a reader running at the same moment (the
# watchdog while a test changes a control) never sees half a file
tmp = f'{state_path}.{os.getpid()}'
with open(tmp, 'w') as f:
json.dump(c, f)
os.replace(tmp, state_path)


def show(name, ctl):
Expand Down
4 changes: 3 additions & 1 deletion packages/omamobile-audio/test/fake-pw
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ if me == 'pw-cli':
if k not in vals or os.environ.get('FAKE_PW_IGNORE') == '1':
continue # the filter ignores unknown controls
vals[k] = float(v)
with open(state, 'w') as f:
tmp = f'{state}.{os.getpid()}'
with open(tmp, 'w') as f:
json.dump(vals, f)
os.replace(tmp, state)
log(args[3])
sys.exit(0)
if me == 'wpctl':
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-audio/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.4
0.5.5