summaryrefslogtreecommitdiff
path: root/examples/host/bare_api
diff options
context:
space:
mode:
authorSaulo Veríssimo <[email protected]>2026-02-25 12:38:44 -0300
committerSaulo Veríssimo <[email protected]>2026-02-25 12:38:44 -0300
commit4d402194dc506a98ed574233cd542ca7f27ff991 (patch)
treebd6c2b57ad91111a09038d372baccc6edff4dbe6 /examples/host/bare_api
parent2e5d5665f3b07dd97b0c34758402be0fbeb1973d (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 'examples/host/bare_api')
0 files changed, 0 insertions, 0 deletions