Skip to content

Commit 660f950

Browse files
committed
ci: gate parity on stable default-device semantics
1 parent d7a2a17 commit 660f950

2 files changed

Lines changed: 72 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ jobs:
5959
run: moon run --target native cmd/enumerate -q
6060
- name: Run differential parity probe
6161
run: node ci/parity/check.js
62+
- name: Upload parity artifacts
63+
if: always()
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: parity-ubuntu
67+
path: _build/parity
68+
if-no-files-found: ignore
6269
- name: Run ALSA smoke (real I/O)
6370
run: moon run --target native cmd/alsa_stream_smoke -q
6471
- name: Run JACK smoke (dummy server)
@@ -91,6 +98,13 @@ jobs:
9198
run: moon run --target native cmd/enumerate -q
9299
- name: Run differential parity probe
93100
run: node ci/parity/check.js
101+
- name: Upload parity artifacts
102+
if: always()
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: parity-macos
106+
path: _build/parity
107+
if-no-files-found: ignore
94108
- name: Run CoreAudio smoke (real I/O)
95109
run: moon run --target native cmd/macos_stream_smoke -q
96110

@@ -144,6 +158,13 @@ jobs:
144158
- name: Run differential parity probe
145159
shell: pwsh
146160
run: node ci/parity/check.js
161+
- name: Upload parity artifacts
162+
if: always()
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: parity-windows
166+
path: _build/parity
167+
if-no-files-found: ignore
147168
- name: Run WASAPI smoke (real I/O)
148169
shell: pwsh
149170
run: moon run --target native cmd/wasapi_stream_smoke -q

ci/parity/check.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,33 @@ function sortStrings(xs) {
8989
return [...xs].sort();
9090
}
9191

92+
function clampMoonInt(value) {
93+
return Math.min(value, 0x7fffffff);
94+
}
95+
9296
function projectConfig(config) {
9397
return {
9498
channels: config.channels,
95-
sample_rate: config.sample_rate,
99+
sample_rate: clampMoonInt(config.sample_rate),
96100
sample_format: config.sample_format,
97101
buffer: {
98102
kind: config.buffer.kind,
99-
min_frames: config.buffer.min_frames,
100-
max_frames: config.buffer.max_frames,
103+
min_frames: clampMoonInt(config.buffer.min_frames),
104+
max_frames: clampMoonInt(config.buffer.max_frames),
101105
},
102106
};
103107
}
104108

105109
function projectRange(range) {
106110
return {
107111
channels: range.channels,
108-
min_sample_rate: range.min_sample_rate,
109-
max_sample_rate: range.max_sample_rate,
112+
min_sample_rate: clampMoonInt(range.min_sample_rate),
113+
max_sample_rate: clampMoonInt(range.max_sample_rate),
110114
sample_format: range.sample_format,
111115
buffer: {
112116
kind: range.buffer.kind,
113-
min_frames: range.buffer.min_frames,
114-
max_frames: range.buffer.max_frames,
117+
min_frames: clampMoonInt(range.buffer.min_frames),
118+
max_frames: clampMoonInt(range.buffer.max_frames),
115119
},
116120
};
117121
}
@@ -150,18 +154,51 @@ function sortDevices(devices) {
150154
);
151155
}
152156

157+
function projectDevice(device) {
158+
return {
159+
id_ok: device.id_ok,
160+
id: device.id,
161+
name_ok: device.name_ok,
162+
name: device.name,
163+
supports_input: device.supports_input,
164+
supports_output: device.supports_output,
165+
has_default_input_config: device.has_default_input_config,
166+
default_input_config: projectConfig(device.default_input_config),
167+
has_default_output_config: device.has_default_output_config,
168+
default_output_config: projectConfig(device.default_output_config),
169+
supported_input_configs_ok: device.supported_input_configs_ok,
170+
supported_output_configs_ok: device.supported_output_configs_ok,
171+
};
172+
}
173+
174+
function projectDefaultDevice(host, kind) {
175+
const hasKey = `has_default_${kind}_device`;
176+
const idOkKey = `default_${kind}_device_id_ok`;
177+
const idKey = `default_${kind}_device_id`;
178+
if (!host[hasKey]) {
179+
return {
180+
present: false,
181+
};
182+
}
183+
const match = host.devices.find(
184+
(device) => device.id_ok === host[idOkKey] && device.id === host[idKey],
185+
);
186+
return {
187+
present: true,
188+
id_ok: host[idOkKey],
189+
id: host[idKey],
190+
listed: match !== undefined,
191+
device: match === undefined ? null : projectDevice(match),
192+
};
193+
}
194+
153195
function sortHosts(hosts) {
154196
return [...hosts]
155197
.map((host) => ({
156198
id: host.id,
157199
devices_ok: host.devices_ok,
158-
has_default_input_device: host.has_default_input_device,
159-
default_input_device_id_ok: host.default_input_device_id_ok,
160-
default_input_device_id: host.default_input_device_id,
161-
has_default_output_device: host.has_default_output_device,
162-
default_output_device_id_ok: host.default_output_device_id_ok,
163-
default_output_device_id: host.default_output_device_id,
164-
devices: sortDevices(host.devices),
200+
default_input_device: projectDefaultDevice(host, 'input'),
201+
default_output_device: projectDefaultDevice(host, 'output'),
165202
}))
166203
.sort((a, b) => a.id.localeCompare(b.id, 'en'));
167204
}

0 commit comments

Comments
 (0)