From 5414d192dfce10d8be7ca7e7053f335ed30bb05b Mon Sep 17 00:00:00 2001 From: Brad Barnett <127794626+bdbarnett@users.noreply.github.com> Date: Fri, 6 Nov 2026 20:32:57 -0600 Subject: [PATCH] MP3: ask the board for its buffered latency A player doesn't need an instrument's latency, and on a board that sizes its ring from it (the GIGA's DAC) more buffering rides out stalls of the interpreter. --- apps/mp3/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/mp3/__init__.py b/apps/mp3/__init__.py index f41ce8c..661f0cb 100644 --- a/apps/mp3/__init__.py +++ b/apps/mp3/__init__.py @@ -152,7 +152,13 @@ def play(i=None): st["out"].close() st["out"] = None if st["out"] is None: - st["out"] = bp.audio_out(AudioFormat(song.sample_rate, song.channel_count, 16)) + fmt_out = AudioFormat(song.sample_rate, song.channel_count, 16) + try: + # A player can trade latency for fewer dropouts: a board + # with a choice buffers more. + st["out"] = bp.audio_out(fmt_out, latency="buffered") + except TypeError: # an audio_out that takes no latency + st["out"] = bp.audio_out(fmt_out) # service() refills the decoder's file buffer from this thread # (the pump on the other core can't read the card): on the app's # timer, so it stops when the app closes.