Skip to content

Avoid enqueueing the deterministic sound poll timer twice - #232

Merged
dingusdev merged 2 commits into
dingusdev:masterfrom
mihaip:upstream-timer-active
Oct 7, 2026
Merged

dingusdev merged 2 commits into
dingusdev:masterfrom
mihaip:upstream-timer-active

Conversation

@mihaip

@mihaip mihaip commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Solarian II repeatedly restarts sound DMA without the stream being closed, and thus we would end up in SoundServer::start_out_stream without going through close_out_stream. The add_cyclic_timer did call did not check if the timer was already active, and we would end up with a duplicate entry in the timer queue, which slowdowns and other incorrect behavior.

Fixed by checking the active flag, like all of the other callsites.

This is partly due to the shared TimerInfo structs refactor from 529fff7 – it's easier to accidentally enqueue the same timer multiple twice. Help the the programmer out by logging an error if the timer is already active when adding it. To also reduce the boilerplate, one-shot timers and and cancellation automatically clear the flag.

The error could be upgraded to a CHECK_F once we're more confident that we've fixed all of the callsites.

mihaip added 2 commits October 6, 2026 11:11
Solarian II repeatedly restarts sound DMA without the stream being
closed, and thus we would end up in `SoundServer::start_out_stream`
without going through `close_out_stream`. The `add_cyclic_timer` did
call did not check if the timer was already active, and we would end up
with a duplicate entry in the timer queue, which slowdowns and other
incorrect behavior.

Fixed by checking the `active` flag, like all of the other callsites.
With the shared `TimerInfo` structs refactor from 529fff7, it's easier
to accidentally enqueue the same timer multiple twice. Help the the
programmer out by logging an error if the timer is already `active` when
adding it. To also reduce the boilerplate, one-shot timers and and
cancellation automatically clear the flag.

The error could be upgraded to a CHECK_F once we're more confident that
we've fixed all of the callsites.
@dingusdev
dingusdev merged commit 315e3d9 into dingusdev:master Oct 7, 2026
7 checks passed
@mihaip
mihaip deleted the upstream-timer-active branch October 9, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants