Skip to content

Dynamic PCM switching in ALSA with multi room audio sync support #443

@Asikbct

Description

@Asikbct

Challenges:
The PCM device is already opened by applications, making it difficult to switch to a new output seamlessly. Since most Music Service SDKs initialize the PCM device at startup, re-initializing it would require users to manually reopen their streaming app and re-select the device, negatively impacting the user experience.

Requirement:
User can switch between different audio output options (Line Out, Optical, USB Out, Bluetooth, etc.) at any time. The transition to a new output should be seamless, whether the user is currently playing a song from any music sources. Playback should resume on the newly selected output without requiring the user to manually reopen the content provider app and restart playback from the beginning.

Problems:

  1. Reopening the PCM
    Most music services open and configure the PCM device during initialization. Changing the PCM device (e.g., switching from Line Out to Optical Out) requires reopening it, which forces music services to reinitialize. This may require the end user to relaunch the respective app, reselect the device, and restart playback, impacting the user experience.
  2. Multiroom Sync
    Many music services that support multiroom synchronization rely on Linux ALSA APIs like snd_pcm_delay() to estimate the kernel buffer fill level and synchronize audio playback across devices. Any new approach to meet the requirements, should not disrupt this synchronization.

I've tried virtual loopback, PulseAudio, and a customized dswitch plugin. While all these methods enable dynamic PCM switching, I couldn't achieve stable long-term latency on the same PCM. Any guidance or suggestions on achieving stable long-term latency along with dynamic PCM switching would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions