zephyr-cp: audiobusio.I2SOut.playing never becomes False after a non-looping sample finishes
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- c
- Domaine
- embedded-iot
Piste de recherche
Start in ports/zephyr-cp/common-hal/audiobusio/I2SOut.c, tracing fill_buffer(), the audio thread's exit, and common_hal_audiobusio_i2sout_get_playing(). Then investigate how Zephyr reports that I2S draining has completed and how thread/slab resources are safely released. Done means a non-looping sample finishes draining without its tail being dropped, playing becomes false, and resources can be used safely by a subsequent play().
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Note: This issue was written by Claude (via Claude Code), not by a human. It was filed at the request of @dhalbert while working on the fixes for #10539.
Summary
On the zephyr-cp port, audiobusio.I2SOut has no end-of-playback detection. After a non-looping sample (loop=False) finishes, I2SOut.playing stays True indefinitely — it is only ever cleared by an explicit stop() (or a write error). So the common idiom
i2s.play(sample, loop=False)
while i2s.playing:
pass
hangs forever.
Where
ports/zephyr-cp/common-hal/audiobusio/I2SOut.c
common_hal_audiobusio_i2sout_get_playing()simply returnsself->playing.self->playingis setFalseonly incommon_hal_audiobusio_i2sout_stop()and on ani2s_writeerror.- When a non-looping sample ends,
fill_buffer()setsself->stopping = trueand triggersI2S_TRIGGER_DRAIN; the audio thread then exits — but leavesself->playing == true.
Relationship to #10539
The single-buffer loop=False "no sound" bug (the final GET_BUFFER_DONE buffer being dropped before it was copied) was fixed for zephyr-cp as part of the #10539 work. This playing-never-clears problem is a separate, deeper gap and was deliberately scoped out, because a correct fix is non-trivial in the current design:
- The audio thread cannot clean itself up (it can't
k_thread_join/free from within itself, and settingplaying = falsethere would break the nextplay(), which guards onplaying). - Clearing it from
get_playing()by callingstop()would issueI2S_TRIGGER_DROP, discarding the still-draining tail blocks (theDRAINjust triggered) and cutting off the end of the sample. - Doing it cleanly requires waiting until the I2S peripheral has actually finished draining (a driver-state query the code does not currently perform) before finalizing and freeing resources.
Suggested direction
Add drain-aware completion detection: once the sample is exhausted and the queued blocks have fully drained, clear playing and release the thread/slab resources — without dropping the tail. This likely needs a Zephyr I2S state query and/or coordination with the audio thread's exit.
Notes
- Affects any non-looping sample on zephyr-cp, not just single-buffer
RawSample;WaveFilewithloop=Falsewould exhibit the same stuckplaying. - Other ports (espressif, nordic, raspberrypi, atmel-samd, ...) clear
playingon completion; this gap is specific to zephyr-cp.
- Langage dominant
- C
- Étoiles
- 4.6k
- Forks
- 1.4k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 153
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de adafruit/circuitpython
-
board breaks api
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
adafruit/circuitpython#11099 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Pico-W: shrink firmware regionOuvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
adafruit/circuitpython#11515 ·
Les mainteneurs répondent en général sous 1 jour
-
Tags and BranchesOuvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
adafruit/circuitpython#11514 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Move silabs to ZephyrOuvertesilabs
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
adafruit/circuitpython#11507 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Feature/API request: portable camera capture across ESP-IDF, Zephyr, and parallel interfacesOuvertecircuitpython api enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
adafruit/circuitpython#11505 · 5 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de adafruit/circuitpython
Issues similaires
-
chore(gateway): emit INFO budget reserved/settled logs for proactivity v2 (chip task_2855f4ec)Ouvertebackend
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
BasedHardware/omi#20940 ·
Les mainteneurs répondent en général sous 1 jour
-
Linux notifications: the default action's ' ' label shows as a blank button in xfce4-notifydOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
kovidgoyal/kitty#10625 ·
Les mainteneurs répondent en général sous 1 jour
-
Feature Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
Les mainteneurs répondent en général sous 1 jour
-
docs
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour