Skip to content

audiopump: a port with no threads can render from an interrupt - #403

Merged
bdbarnett merged 1 commit into
mainfrom
irq-render-2
Nov 10, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
irq-render-2

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

A driver that renders from an interrupt sets the new render_kick hook in its port ops. audiopump.service() on the interpreter then asks the driver to render instead of running the pump itself, and the interpreter's changes to the pump in service mode (spawn, stop, park, teardown, and a service call from C) take the pump lock, which such a driver implements by holding its interrupt off. AUDIODSP_PORT_IRQ_HOOKS tells a driver the header has the hook.

This is what lets the Arduino GIGA R1 render from its DAC interrupt, so a long garbage collection, a flash write or Python Bluetooth callbacks no longer leave the DAC with nothing to play. With the GIGA driver from micropython-pydevices#392, ten minutes of Synth Station with a collection every 3 s and a 32 KB flash write every 30 s starved 0 of 28.7M frames, against 1,000,908 on the build before.

With render_kick NULL, as on every other port, the only change is the lock taken around the service-mode tail drop and launch, on ports that already render from the interpreter. unix renders are byte-identical (same sha256) before and after, and the audioif probes pass. ESP32 and Windows weren't run; they render on a thread and don't take the service-mode paths.

A driver that renders from an interrupt sets the new render_kick hook.
audiopump.service() on the interpreter then asks it to render instead of
running the pump itself, and the interpreter's changes to the pump in
service mode (spawn, stop, park, teardown, and a service call from C) take
the pump lock, which such a driver implements by holding its interrupt off.
With render_kick NULL, as on every port today, nothing changes.
@bdbarnett
bdbarnett merged commit 46e9224 into main Nov 10, 2026
35 checks passed
@bdbarnett
bdbarnett deleted the irq-render-2 branch November 10, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant