zephyr-cp: audiobusio.I2SOut.playing never becomes False after a non-looping sample finishes
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- c
- 領域
- embedded-iot
調査の方向性
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().
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C
- スター
- 4.6k
- フォーク
- 1.4k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 153
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
adafruit/circuitpython のほかの issue
-
board breaks api
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
adafruit/circuitpython#11099 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
adafruit/circuitpython#11515 ·
メンテナーはふだん 1 日以内に返信
-
Tags and Branchesオープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
adafruit/circuitpython#11514 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
silabs
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
adafruit/circuitpython#11507 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
circuitpython api enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
adafruit/circuitpython#11505 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
adafruit/circuitpython の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kovidgoyal/kitty#10625 ·
メンテナーはふだん 1 日以内に返信
-
Feature Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RubyMetric/chsrc#396 ·