Skip to content

AudioOutputRouter: prune dead (QPointer-null) followers / add deregistration #3660

Description

@ten9876

Summary

Follow-up nit from the review of #3630 (AudioOutputRouter, part of #3306). Non-urgent.

AudioOutputRouter never prunes followers whose QPointer guard has gone null. When a registered sink is destroyed before the router, its entry stays in m_followers as a no-op closure that is still iterated (and skipped) on every setCurrentDevice() fan-out.

Why it's harmless today

The router is register-once-at-startup with exactly two followers (ClientPuduMonitor, QsoRecorder), both owned for the app lifetime, and the guarded lambda is correct (it just does nothing when null). So there's no functional bug and no meaningful cost right now.

Why it's worth tidying

The accumulation only matters if the registry ever gains dynamically created/destroyed followers (e.g. a future per-receiver or WebSDR-sourced sink — see the aux-output-sink work queued in docs/audio-sink-factory.md). Then stale null entries would grow unbounded.

Proposed fix

Either:

  • Prune during fan-out — drop entries whose guard is null while iterating the snapshot (compact m_followers after the loop), or
  • Add a removeFollower() / return a small handle from addFollower() for explicit deregistration.

The std::function overload has no guard, so a handle/removeFollower is the more general answer if dynamic followers ever land.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    audioAudio engine and streamingenhancementImprovement to existing featuregood first issueGood for newcomersmaintainer-reviewRequires maintainer review before any action is takenpriority: lowLow priority

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions