Conversation
added 3 commits
September 8, 2026 13:24
Protect circular-buffer writes from the DMA consumer so it cannot observe a partially copied block or race the buffer bookkeeping. Signed-off-by: Ray Bellett <shinko@netcavy.net>
The audio drivers already deliver refill callbacks on KernelBG. Avoid queuing another callback and refill the reported free capacity after a delayed stream callback. Signed-off-by: Ray Bellett <shinko@netcavy.net>
Hold a raised KernelBG priority while audio is active. Reference-count priority requests so stopping playback cannot release another user's request. Signed-off-by: Ray Bellett <shinko@netcavy.net>
Author
|
https://github.com/ShinkoNet/pebbleboy |
jplexer
requested changes
Sep 14, 2026
| prv_update_volume_analytics(effective_vol); | ||
|
|
||
| // Keep DMA refills ahead of CPU-heavy app work until playback stops. | ||
| system_task_enable_raised_priority(true); |
Member
There was a problem hiding this comment.
This boosts all KernelBG callbacks above the app for the entire playback lifetime, including long-lived streams. Can the priority boost be scoped to pending refill work instead, so unrelated background callbacks do not also preempt the app?
| static void prv_audio_trans_cb(uint32_t *free_size) { | ||
| // Schedule actual refill work on system task to keep ISR-context callback short | ||
| system_task_add_callback(prv_refill_bg, NULL); | ||
| // The drivers already dispatch on KernelBG; refill here and catch up missed blocks. |
Member
There was a problem hiding this comment.
This assumes free_size is the amount currently writable, but the QEMU driver always passes a hard-coded full-buffer size (4096 * sizeof(int16_t)) on every interrupt. Would need to be changed in the QEMU driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CPU-heavy apps can leave speaker PCM refills late. The driver already dispatches its callback on KernelBG, but the service queues another callback, refills only one block after a delay, and leaves KernelBG below app priority. The SF32LB circular buffer also publishes its length before copying bytes while the DMA interrupt consumes the same buffer.
Tested on Pebble Time 2, and also confirmed QEMU still output audio.
I've been working on a Game Boy Color emulator, and it creates a lot of CPU usage. These audio fixes were tested in my own fork along with my emulator (Pebbleboy) to confirm the audio no longer stuttered during emulation.