Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify different behaviors for no sink ID and the default sink ID (""). #2596

Open
hoch opened this issue Jul 27, 2024 · 4 comments
Open

Specify different behaviors for no sink ID and the default sink ID (""). #2596

hoch opened this issue Jul 27, 2024 · 4 comments

Comments

@hoch
Copy link
Member

hoch commented Jul 27, 2024

First, the spec currently does not explain the default behavior of automatic fallback upon device change or failure. For example, if the system default audio device changes, the AudioContext doesn't do anything actively. It simply follows whatever the platform offers.

This is how the conventional AudioContext works:

const context = new AudioContext();

However, the spec now provides a new way of selecting an output device via the context constructor, and also there's a way to specify the system default audio device. ("")

const context = new AudioContext({sinkId: ""});

While we were experimenting with this feature in Chromium, we thought it would be beneficial to developers to distinguish two different cases.

For the former, it should be completely backward compatible and the context will try to follow whatever the output device provided by the platform. On the other hand, the latter expresses the developer's intent to use the default audio device "specifically", thus it should follow the device selection logic as written on the spec. It means that if the current selected audio device changes, the context will be suspended and onerror will be dispatched.

@o1ka
Copy link

o1ka commented Aug 7, 2024

The system default is the system default. AudioContext should not do anything active with it. Specifying "" (or specifying nothing) means "always render to the user agent default device". Following what platform offers is the whole idea.

If an app wants to choose a specific device, which is currently also a user-agent default - it should pick up a corresponding specific device id from device enumeration (the information is available there), rather than use "".

The only difference between new AudioContext() and new AudioContext({sinkId: ""}) I personally would like to see, is that while a context created via new AudioContext() is silently falling to a null sink rendering in case there are no devices available (legacy behavior), it would be beneficial for new AudioContext({sinkId: ""}) instead of a silent failure to dispatch onerror and suspend.

@mjwilson-google
Copy link
Contributor

The only difference between new AudioContext() and new AudioContext({sinkId: ""}) I personally would like to see, is that while a context created via new AudioContext() is silently falling to a null sink rendering in case there are no devices available (legacy behavior), it would be beneficial for new AudioContext({sinkId: ""}) instead of a silent failure to dispatch onerror and suspend.

I think this is exactly what is being proposed:

For the former, it should be completely backward compatible and the context will try to follow whatever the output device provided by the platform. On the other hand, the latter expresses the developer's intent to use the default audio device "specifically", thus it should follow the device selection logic as written on the spec. It means that if the current selected audio device changes, the context will be suspended and onerror will be dispatched.

@o1ka
Copy link

o1ka commented Aug 7, 2024

What does

if the current selected audio device changes

mean in the context of the default output device? The default output device always remains the default output device. It may be configured as different physical devices at different points in time, but switching the default from one physical device to another should be transparent. This is the whole idea: "use whatever is system default".
And this is how it's interpreted by the media element as well.

What is the difference between using the default device, and using the default device "specifically"? What does "specifically" mean? What is the use case behind this wording?

Note that in the comment above I'm talking about dispatching onerror when the system lost all output devices, so there is no default output device any longer. But the proposal is talking about "the current selected audio device changes", which I can only interpret as "system configuration switched to using another physical device as default". If this is not the intended meaning, it would be nice to clarify and rephrase.

@mjwilson-google
Copy link
Contributor

Note that in the comment above I'm talking about dispatching onerror when the system lost all output devices, so there is no default output device any longer. But the proposal is talking about "the current selected audio device changes", which I can only interpret as "system configuration switched to using another physical device as default". If this is not the intended meaning, it would be nice to clarify and rephrase.

I see, yes I think they are different. I think we should discuss this with the Working Group.

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

No branches or pull requests

3 participants