Skip to content

Choose the renderer's format-change delay per sound card #233

Description

@madenvel

Problem

output.format_change_delay_ms makes the renderer wait after it opens the ALSA device or sets a new format, before it starts playback. A HiFiBerry HAT on a Raspberry Pi needs the wait: without it, the start of a track can be cut off. A tester also saw a whole device open stay silent after a Spotify-to-Qobuz handoff. The renderer played at real-time pace, but nothing written to that device was heard until it was reopened.

The renderer now waits 500 ms by default for every card. That's the value the Pi package shipped until June 2025. A USB DAC, or a desktop's built-in card, doesn't need it and pays 500 ms of extra start latency on every device open and every format change. Every handoff between plugins reopens the device, so this cost is paid often.

Proposal

Choose the default per device instead of one value for everything:

  • Identify the card behind output.device (the ALSA card id and driver, and whether it's USB). AlsaDeviceEnumeration already reads this.
  • Look the card up in a small table of known cards, e.g. HiFiBerry HATs (sndrpihifiberry and similar I2S cards) → 500 ms, USB audio class → 0 ms.
  • Fall back to a type-based default when the card isn't in the table: I2S HATs on a Pi get the delay, USB and PCI cards don't.
  • A value the user sets by hand always wins over the table.
  • The settings page shows the chosen value as the default for the selected card, so users can see where it came from.

output.reopen_on_format_change is the same kind of per-DAC workaround and could come from the same table.

Done when

  • The default delay depends on the selected card, and changing output.device changes the default.
  • A HiFiBerry HAT still gets 500 ms, and a USB DAC gets 0 ms, with no configuration.
  • Unit tests in packages/kalinka-renderer/tests/ cover the table lookup, the type-based fallback and the user override.

Activity

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

    confirmedReproduced or confirmed in the codeenhancementNew feature or requestpriority: P2Worth doing; planned by valuetriagedSeen and prioritised

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions