Skip to content

Device Dis-/Connection Notifications #1332

Description

@LastExceed

Summary of a discussion on Discord

Description

@edwloef
API idea: some way to get notified for audio device connects/disconnects? E.g. Discord shows a popup when a new audio device becomes available

Prior Art

@roderickvd:
Right now, ErrorKind has DeviceChanged and DeviceNotAvailable (which includes disconnections). On hosts that support it, DeviceChanged is emitted when a default device is opened and is rerouted to another device.
@edwloef:
Yeah, but for that you need to have a stream open on the default device.

Host Support

Host Support Docs
AAudio
ALSA
ASIO ❌¹ N/A
AudioWorklet
CoreAudio ✔️ link
JACK ✔️ link
PipeWire ✔️ link
PulseAudio ✔️ link
WASAPI ✔️ link
WebAudio

¹Of course, this feature could be emulated for any host by periodically polling the device list

Design Proposals

@LastExceed
maybe a callback? or a message channel ?
@edwloef
I'd say a callback + a handle, similar to an audio stream.
@ mikedorf
It would be nice to have a futures::Stream at the low level but I understand that not everyone is using async and the APIs may force you to wire a callback anyway
@roderickvd
It would probably have to live on Host and get registered, like register_notification with a device ID indeed plus a callback, returning a notification handle that you could drop or unregister. And for the callback to handle a notification kind and payload.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions