diff options
| author | Saulo Veríssimo <[email protected]> | 2026-02-25 12:38:44 -0300 |
|---|---|---|
| committer | Saulo Veríssimo <[email protected]> | 2026-02-25 12:38:44 -0300 |
| commit | 4d402194dc506a98ed574233cd542ca7f27ff991 (patch) | |
| tree | bd6c2b57ad91111a09038d372baccc6edff4dbe6 /src/portable | |
| parent | 2e5d5665f3b07dd97b0c34758402be0fbeb1973d (diff) | |
midi device: add cable-aware stream read (tud_midi_n_demux_stream_read)
The existing tud_midi_n_stream_read() accepts a cable_num parameter but
ignores it — all cables share a single FIFO and stream parser state, so
data from different virtual cables is silently mixed together.
Add tud_midi_n_demux_stream_read() which returns the cable number of the
data that was actually read. It peeks at each USB-MIDI event packet
header before consuming it and stops when the next packet belongs to a
different cable, allowing callers to dispatch per-cable without losing
data.
Implementation details:
- Mirrors the host-side tuh_midi_stream_read() approach: tu_edpt_stream_peek
for cable inspection, CIN-based byte count (USB MIDI 1.0 Table 4-1),
leftover handling via existing midi_driver_stream_t
- *p_cable_num initialized to 0xff sentinel so callers can detect
"no data" even when return value is 0
- Cable-change check (total_read > 0 guard) covers both leftover-originated
reads and freshly consumed packets
- TU_VERIFY uses explicit != NULL comparisons, consistent with codebase style
- Note: shares stream->buffer with tud_midi_n_stream_read(); do not mix
calls on the same interface
- Adds single-interface convenience wrapper tud_midi_demux_stream_read()
Closes #1838
Diffstat (limited to 'src/portable')
0 files changed, 0 insertions, 0 deletions
