Skip to content

mac-capture: CoreAudio reconnect retries full device init forever at 300 ms / 2 s with no backoff #1358

Closed

Description

@zackees

Part of #1273 (found by the #1285 capture-plugin audit). B, retries forever without backoff.

plugins/mac-capture/mac-audio.c.h:463-467: the CoreAudio reconnect thread retries a full coreaudio_init (device lookup and AudioUnit setup) at a fixed interval:

while (os_event_timedwait(ca->exit_event, ca->retry_time) == ETIMEDOUT) {
	if (coreaudio_init(ca))
		break;
}

retry_time is 300 ms after a default-device change and 2000 ms after an unplug or a failed first init (set at ~500 and ~730).

Failure scenario: with the device gone for good (an unplugged interface, a removed aggregate device), the source retries for its whole life. On the 300 ms path that is about 3 full device inits per second, indefinitely. It runs on its own thread, so there is no spin and no UI stall, but it's the retry-forever pattern.

Fix:

  • Exponential backoff, for example starting at retry_time and doubling to a cap of about 10–30 s.
  • Reset on a CoreAudio device-list or default-device change notification, which is the moment a retry can actually succeed.
  • Log once when the backoff reaches its cap.

Test: with a fake coreaudio_init that always fails, the attempt count over about 20 s follows the backoff, and a device-change notification resets it.

Activity

  1. zackees commented on Oct 17, 2026

    @zackees
    MemberAuthor

    Claiming. Plan: exponential backoff for the CoreAudio reconnect (start at today's retry_time, double to a ~30 s cap), reset when CoreAudio reports a device-list or default-device change, one log line when the cap is reached. The backoff schedule goes in a pure helper with a Tier 1 cmocka test (simulated time; always-failing init, reset on notification) that runs on Linux; the macOS wiring is compile-checked by PR CI's macOS lane.

  2. added
    claimedAn agent or person has claimed this; check the claim comment before starting
    on Oct 17, 2026
  3. removed
    claimedAn agent or person has claimed this; check the claim comment before starting
    on Oct 20, 2026
  4. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Fixed by #1370 (merged). That PR used Refs, so the issue stayed open, but its body lists no remaining work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions