Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

soundcard.py: start the card and return to the REPL - #82

Merged
bdbarnett merged 1 commit into
mainfrom
soundcard-repl
Oct 10, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
soundcard-repl

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

The pump moves the audio in C, so main() no longer loops printing counters: it starts the card (and its spectrum, on a board with a display) and returns, and the REPL stays usable while it plays. Beside it: stats() prints the pump's counters once, watch() prints them every second until Ctrl-C, and stop() stops the spectrum, the pump and then the amp.

Two things this exposed, both handled:

  • A soft reset leaves the C pump running (its buffers aren't on the Python heap), still holding I2S, so the next uac_pump_start() failed with OSError: 259. main() now stops a pump left running before it starts one. The spectrum's meter is safe across the reset: its finaliser detaches it from the sound card.
  • stop() then main() failed with "another Meter is attached": stop() now stops the meter and releases it. _spectrum() also treats that OSError like its other reasons for no spectrum, so the card plays either way.

Checked on the ESP32-P4 WIFI6 DEV-KIT (KeDei panel) with music playing from Windows: a cold boot, three stop()/main() cycles at the REPL and three soft resets, each with the spectrum back, no errors, and audio moving at about 100 KB/s afterwards. Each restart counts 6-7 pump timeouts once (the host re-attaching the card) and none after.

@bdbarnett
bdbarnett merged commit f3f16c6 into main Oct 10, 2026
6 checks passed
@bdbarnett
bdbarnett deleted the soundcard-repl branch October 10, 2026 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant