#766: Output Device Selection in Web Audio API: AudioContext.setSinkId()

Visit on Github.

Opened Aug 30, 2022

Hello,

I'm requesting a TAG review of AudioContext.setSinkId().

AudioContext.setSinkId sets the ID of the audio device to use for output. This allows the AudioElement to route audio to a connected output device of user's choosing.

  • Explainer, User research, Security and Privacy self-review: Public Design Doc
  • Primary contacts (and their relationship to the specification):
    • Hongchan Choi (@hoch), Google
    • Paul Adenot (@padenot), Mozilla
  • Organization/project driving the design: W3C Audio WG
  • External status/issue trackers for this feature: https://chromestatus.com/feature/5190163462881280

Further details:

We'd prefer the TAG provide feedback as (please delete all but the desired option): ☂️ open a single issue in our GitHub repo for the entire review

Discussions

Comment by @hoch Sep 7, 2022 (See Github)

Adding @svgeesus for visibility: we initially discussed this feature is too small for TAG review, but I am requesting it here per Chrome's launch process.

Comment by @svgeesus Sep 9, 2022 (See Github)

TAG review of small, focused features is perfectly fine.

Comment by @svgeesus Sep 9, 2022 (See Github)

some useful abilities will also be included: a) an ability to specify an output device in the AudioContext’s constructor and b) an ability to specify a “silent output device” to minimize the power consumption.

A sentence motivating the user need for each of those two improvements would be a helpful addition to the explainer. Why does WebAudio API need them? Why does HTML not have them, and should it?

Comment by @hoch Sep 12, 2022 (See Github)

Thanks for the feedback, @svgeesus! I've added the "Motivation" section on the explainer. (i.e. public design doc above)

Why does HTML not have them, and should it?

For this question, I am not sure if I can answer it with confidence. For what it's worth, there's a method selectAudioOutput() under MediaDevices, but I don't think that is suitable for Web Audio API.

Discussed Oct 1, 2022 (See Github)

Max: Had a look at the explainer... very good question asked by Chris - why does web audio API need them... and why does HTML not have them... and should it? Also looked at the design of the API.. a lot of questions of other ways to work around this... one suggestion is to suggest the author to update the explainer to answer the 2nd question - why HTML doesn't solve the problem.. a selectaudiooutput api can do the same thing - but authors should update the explainer to explain why this API is not suitable for web audio...

Dan: that sounds great..

Max to leave comment accordingly

Sangwhan: is it an output device request?

Max: to enable the developer to select the output...

Sangwhan: user choice

Max: from the github discussion looks like the user also gets a notification...

Dan: Web Audio community have good track record... Also notable that this is multi-stakeholder (Google and Mozilla).

Sangwhan: concern: any API recently minted with a device selector -- firstly it would be a promise... You'd have the UA give a selector.. trying to understand if that pattern exists here or not... The issue opened in 2014... Some legacy elements about implicit device choice in Web Audio API that don't match current patterns.

Discussed Oct 1, 2022 (See Github)

Max: the author responded to last week's comment and provided information

Dan: it's a compelling argument. Worrying that they're saying there's another feature of another api that would partially solve the problem but it isn't implemented in browsers so that's why they need this. Why isn't in implemented? Maybe it should be deprecated.

Amy: and why would this be implemented in browsers instead?

Dan: they're working on web audio. There's this other thing that's happened in a different WG. That's media capture which is part of webrtc

Max: they also mention in the last sentence - even with that ..

Dan: generally we were happy with this other than that. There is the fact that it has multiple stakeholders.. It does talk about a user need. Privacy review.

<blockquote> Thanks for this review request. We're happy to see this move forward and we're espeicially glad to see it do so with multiple stakeholder support and the attention to privacy considerations. We are slightly concerned that some of the functionality is duplicated elsewhere in the platform, however we undertand the different context. Can you please move the explainer into a markdown file in the appropriate repo? </blockquote>

agreed to close

Comment by @maxpassion Oct 11, 2022 (See Github)

Thanks for the feedback, @svgeesus! I've added the "Motivation" section on the explainer. (i.e. public design doc above)

Why does HTML not have them, and should it?

For this question, I am not sure if I can answer it with confidence. For what it's worth, there's a method selectAudioOutput() under MediaDevices, but I don't think that is suitable for Web Audio API.

Hi @hoch, you mentioned that selectAudioOutput() is not suitable for Web Audio API, could you update the explainer document to explain the reason behind the design choices?

Comment by @hoch Oct 13, 2022 (See Github)

@maxpassion Here's my response to the question (link):

Using selectAudioOutput() under MediaDevices:

Although the Audio Output Device API spec mentions briefly about AudioContext, it lacks the detail of how Web Audio API is controlled by this method. (As of writing, no browser has implemented this feature) Additionally, the method is designed to change the audio output device for all instances of MediaElement and AudioContext in a document. Even with the implementation of selectAudioOutput(), AudioContext doesn't have the ability to set the output device separately whereas AudioElement does.

Comment by @torgo Oct 18, 2022 (See Github)

Thanks for this review request. We're happy to see this move forward and we're especially glad to see it do so with multiple stakeholder support and the attention to privacy considerations. We are slightly concerned that some of the functionality is duplicated elsewhere in the platform, however we understand the different context. Can you please move the explainer into a markdown file in the appropriate repo? 🎶

Comment by @hoch Oct 18, 2022 (See Github)

@torgo Thanks for your review! I'll move the explainer to https://github.com/WebAudio/web-audio-api.