Skip to content

Commit 17f828a

Browse files
committed
ALSA enumerate metadata; avoid probing supports_input/output
1 parent 6a40392 commit 17f828a

11 files changed

Lines changed: 387 additions & 284 deletions

.beads/issues.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{"id":"moon_cpal-uao.41","title":"Parity: host/mod.rs","description":"Align with cpal-reference/src/host/mod.rs (native-only). Ensure HostId/HostTrait wiring and host module structure matches upstream.\\n\\nAcceptance:\\n- HostTrait/DeviceTrait/StreamTrait equivalents exist and match upstream method behavior.","status":"closed","priority":2,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:03.095379+08:00","created_by":"Milky2018","updated_at":"2026-02-05T10:46:15.959018+08:00","closed_at":"2026-02-05T10:46:15.959018+08:00","close_reason":"Added MoonBit CPAL-like traits in new package Milky2018/moon_cpal/traits and implemented for spec Host/Device/Stream (typed + raw stream builders).","dependencies":[{"issue_id":"moon_cpal-uao.41","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:03.097658+08:00","created_by":"Milky2018"}]}
6969
{"id":"moon_cpal-uao.42","title":"Parity: host/null/mod.rs","description":"Align with cpal-reference/src/host/null/mod.rs. Ensure Null host/device/stream behaviors (including error semantics) match upstream wherever applicable.\\n\\nAcceptance:\\n- Null host passes all portable parity tests (callbacks, pause/play/close semantics).","status":"closed","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:03.294486+08:00","created_by":"Milky2018","updated_at":"2026-02-05T11:34:28.911974+08:00","closed_at":"2026-02-05T11:34:28.911974+08:00","close_reason":"Closed","dependencies":[{"issue_id":"moon_cpal-uao.42","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:03.297979+08:00","created_by":"Milky2018"}],"comments":[{"id":4,"issue_id":"moon_cpal-uao.42","author":"Milky2018","text":"Aligned MoonBit null backend to upstream cpal null host semantics: Host.devices() empty; default_{in,out}_device() None; supported/default config + stream builders raise backend-specific errors; Stream play/pause unimplemented. Moved deterministic callback-thread test backend into internal/test_host for portable lifecycle/timing tests.","created_at":"2026-02-05T03:34:28Z"}]}
7070
{"id":"moon_cpal-uao.43","title":"Parity: host/alsa/enumerate.rs","description":"Align ALSA device enumeration behavior with cpal-reference/src/host/alsa/enumerate.rs (native-only).\\n\\nAcceptance:\\n- devices(), default devices, and DeviceId/name semantics match upstream as closely as possible.","notes":"2026-02-05: Improve enumeration parity: ALSA devices now include both libasound hints and /proc hw:/plughw: entries (deduped), and default_{input,output}_device now always returns the default PCM like upstream.","status":"closed","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:03.508687+08:00","created_by":"Milky2018","updated_at":"2026-02-05T10:29:06.630858+08:00","closed_at":"2026-02-05T10:17:18.171827+08:00","close_reason":"ALSA devices_utf8 now emits hw/plughw CARD/DEV ids; Host::devices no longer filters by probing; added enumeration test.","dependencies":[{"issue_id":"moon_cpal-uao.43","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:03.510299+08:00","created_by":"Milky2018"}]}
71-
{"id":"moon_cpal-uao.44","title":"Parity: host/alsa/mod.rs","description":"Align ALSA host/device/stream behavior with cpal-reference/src/host/alsa/mod.rs (native-only).\\n\\nAcceptance:\\n- default/supported configs parity via real ALSA hw_params queries (where possible).\\n- Error mapping parity for common ALSA failures.","status":"open","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:03.702535+08:00","created_by":"Milky2018","updated_at":"2026-02-04T21:39:03.702535+08:00","dependencies":[{"issue_id":"moon_cpal-uao.44","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:03.704646+08:00","created_by":"Milky2018"}],"comments":[{"id":1,"issue_id":"moon_cpal-uao.44","author":"Milky2018","text":"Improved error classification: ALSA supported config probing now returns status+records (i32 errno + u32 count header) and raises SupportedStreamConfigsError (ENODEV/EBUSY/EINVAL mapping). BuildStreamError maps EINVAL-\u003eInvalidArgument.","created_at":"2026-02-05T02:17:18Z"},{"id":8,"issue_id":"moon_cpal-uao.44","author":"Milky2018","text":"ALSA parity progress: device enumeration now mirrors upstream (always includes 'default', plus snd_device_name_hint devices and hw/plughw CARD/DEV from /proc/asound/pcm with dedupe). supported_{in,out}_configs now use real ALSA hw_params probing via a binary FFI result and map common errno codes to SupportedStreamConfigsError. BufferSize::Fixed validation now matches upstream semantics (Fixed(0) -\u003e StreamConfigNotSupported; out-of-range -\u003e StreamConfigNotSupported).","created_at":"2026-02-05T04:22:15Z"}]}
71+
{"id":"moon_cpal-uao.44","title":"Parity: host/alsa/mod.rs","description":"Align ALSA host/device/stream behavior with cpal-reference/src/host/alsa/mod.rs (native-only).\\n\\nAcceptance:\\n- default/supported configs parity via real ALSA hw_params queries (where possible).\\n- Error mapping parity for common ALSA failures.","status":"open","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:03.702535+08:00","created_by":"Milky2018","updated_at":"2026-02-04T21:39:03.702535+08:00","dependencies":[{"issue_id":"moon_cpal-uao.44","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:03.704646+08:00","created_by":"Milky2018"}],"comments":[{"id":1,"issue_id":"moon_cpal-uao.44","author":"Milky2018","text":"Improved error classification: ALSA supported config probing now returns status+records (i32 errno + u32 count header) and raises SupportedStreamConfigsError (ENODEV/EBUSY/EINVAL mapping). BuildStreamError maps EINVAL-\u003eInvalidArgument.","created_at":"2026-02-05T02:17:18Z"},{"id":8,"issue_id":"moon_cpal-uao.44","author":"Milky2018","text":"ALSA parity progress: device enumeration now mirrors upstream (always includes 'default', plus snd_device_name_hint devices and hw/plughw CARD/DEV from /proc/asound/pcm with dedupe). supported_{in,out}_configs now use real ALSA hw_params probing via a binary FFI result and map common errno codes to SupportedStreamConfigsError. BufferSize::Fixed validation now matches upstream semantics (Fixed(0) -\u003e StreamConfigNotSupported; out-of-range -\u003e StreamConfigNotSupported).","created_at":"2026-02-05T04:22:15Z"},{"id":11,"issue_id":"moon_cpal-uao.44","author":"Milky2018","text":"ALSA enumerate parity step: alsa_devices_utf8 now emits per-device metadata (id + direction tag + escaped DESC), and Host::devices parses into Device{ id, desc, direction }. Device::name now returns pcm_id (upstream parity) and Device::description uses hint/proc desc lines + driver=pcm_id without opening the device. Added Device::supports_input/output using stored direction and updated platform.Device::supports_* to avoid probing for ALSA/JACK.","created_at":"2026-02-05T04:55:11Z"}]}
7272
{"id":"moon_cpal-uao.45","title":"Parity: host/jack/mod.rs","description":"Align JACK host module with cpal-reference/src/host/jack/mod.rs (native-only).\\n\\nAcceptance:\\n- Device model, default devices, and host-level behaviors match upstream.","status":"open","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:13.504619+08:00","created_by":"Milky2018","updated_at":"2026-02-04T21:39:13.504619+08:00","dependencies":[{"issue_id":"moon_cpal-uao.45","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:13.508482+08:00","created_by":"Milky2018"}],"comments":[{"id":9,"issue_id":"moon_cpal-uao.45","author":"Milky2018","text":"JACK parity progress: fixed buffer semantics tightened (Fixed(0) -\u003e StreamConfigNotSupported; mismatch -\u003e StreamConfigNotSupported when server config known). Updated buffer/timing/error mapping tests accordingly.","created_at":"2026-02-05T04:22:15Z"}]}
7373
{"id":"moon_cpal-uao.46","title":"Parity: host/jack/device.rs","description":"Align JACK device semantics with cpal-reference/src/host/jack/device.rs.\\n\\nAcceptance:\\n- DeviceId/name/direction, config queries, and error semantics match upstream.","status":"open","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:13.70983+08:00","created_by":"Milky2018","updated_at":"2026-02-04T21:39:13.70983+08:00","dependencies":[{"issue_id":"moon_cpal-uao.46","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:13.711465+08:00","created_by":"Milky2018"}]}
7474
{"id":"moon_cpal-uao.47","title":"Parity: host/jack/stream.rs","description":"Align JACK stream semantics with cpal-reference/src/host/jack/stream.rs.\\n\\nAcceptance:\\n- Callback timing, buffer sizing, and error invalidation semantics match upstream.","status":"open","priority":3,"issue_type":"task","owner":"842376130@qq.com","created_at":"2026-02-04T21:39:13.925089+08:00","created_by":"Milky2018","updated_at":"2026-02-04T21:39:13.925089+08:00","dependencies":[{"issue_id":"moon_cpal-uao.47","depends_on_id":"moon_cpal-uao","type":"parent-child","created_at":"2026-02-04T21:39:13.926672+08:00","created_by":"Milky2018"}]}

UPSTREAM_PARITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Top-level:
3636
Native hosts:
3737

3838
- `host/null/mod.rs`**DONE** (fallback host only; no devices; stream/config APIs are unimplemented; deterministic callback-thread tests live in `internal/test_host`)
39-
- `host/alsa/enumerate.rs`**PARTIAL**
39+
- `host/alsa/enumerate.rs`**PARTIAL** (hints + hw/plughw physical IDs, direction+DESC metadata; still missing alsa-rs style physical probing parity)
4040
- `host/alsa/mod.rs`**PARTIAL**
4141
- `host/jack/device.rs`**PARTIAL**
4242
- `host/jack/stream.rs`**PARTIAL**

alsa/alsa_enumerate_test.mbt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,39 @@ test "alsa: default devices are always Some (linux-only)" {
4646
Some(d) => inspect(d.id == "default", content="true")
4747
}
4848
}
49+
50+
///|
51+
test "alsa: name + description fields (best-effort)" {
52+
if @core.native_os() != @core.NativeOs::Linux {
53+
inspect(true, content="true")
54+
return
55+
}
56+
let h = default_host()
57+
let ds = h.devices()
58+
if ds.length() == 0 {
59+
inspect(true, content="true")
60+
return
61+
}
62+
let d = ds[0]
63+
inspect(d.name() == d.id, content="true")
64+
let desc = try d.description() catch {
65+
_ => {
66+
inspect(true, content="true")
67+
return
68+
}
69+
} noraise {
70+
x => x
71+
}
72+
inspect(desc.driver() == Some(d.id), content="true")
73+
// Direction must be stable and never contradict itself.
74+
match desc.direction() {
75+
@core.DeviceDirection::Input => inspect(d.supports_input(), content="true")
76+
@core.DeviceDirection::Output =>
77+
inspect(d.supports_output(), content="true")
78+
@core.DeviceDirection::Duplex => {
79+
inspect(d.supports_input(), content="true")
80+
inspect(d.supports_output(), content="true")
81+
}
82+
@core.DeviceDirection::Unknown => inspect(true, content="true")
83+
}
84+
}

0 commit comments

Comments
 (0)