setSinkId() on a media element with MediaStream srcObject hangs until playback ends, when device cannot be opened
Categories
(Core :: WebRTC: Audio/Video, defect)
Tracking
()
People
(Reporter: karlt, Unassigned)
References
Details
When cubeb fails to init or start an output stream to the device specified by setSinkId() on a media element with a MediaStream srcObject, Gecko does not resolve the setSinkId() promise until either a subsequent (automatically repeated) attempt to start a stream succeeds or playback ends.
This differs from Gecko's behavior for a media element decoding a media resource, where the promise would be resolved after attempting to start the stream, whether or not that succeeds.
A disadvantage of the behavior with a MediaStream srcObject is that there can be a long (indefinite) period during which content does not know which device is the "underlying audio output device". The sinkId attribute on the media element is still set to the previous device, but that is no longer being used for output.
| Reporter | ||
Comment 1•2 years ago
|
||
The relevant specified parallel steps are:
- If sinkId is not the empty string and does not match any audio output device identified by the result that would be provided by enumerateDevices(), reject p with a new DOMException whose name is NotFoundError and abort these substeps.
- Switch the underlying audio output device for element to the audio device identified by sinkId.
- If the preceding substep failed, reject p with a new DOMException whose name is AbortError, and abort these substeps.
- Queue a task that runs the following steps:
- Set element's [[SinkId]] to sinkId.
- Resolve p.
Arguably, the behavior with a MediaStream srcObject is compliant because Gecko is taking a long time to "Switch the underlying audio output device".
| Reporter | ||
Comment 2•2 years ago
|
||
Also related is the specified behavior of no action when the underlying device becomes unavailable.
The audio device identified by a media element's sinkId attribute may become unavailable, for example if it is unplugged.
When the audio device identified by the sinkId attribute is no longer available, the user agent must take no action. For example, if the media element's paused attribute is false when the device identified by the sinkId is no longer available, then playback will continue as normal. In this case, audio will not be rendered because the device to which the media element is attached is unavailable.
There is a time sometime during setSinkId(), when the implementation must determine whether to resolve or reject the promise according to whether the device is available. After this point, no action is taken if the device becomes unavailable.
Gecko similarly takes no action if an error occurs on the device, when the device may or may not still be available, as indicated by enumerateDevices() and "devicechange" events.
| Reporter | ||
Comment 3•2 years ago
|
||
The behavior when decoding a media resource is as if the underlying device is switched if the device is present in device enumeration. This behavior was chosen on consideration of some additional factors:
- Not wanting to start a cubeb stream if it is not required, such as when playback is paused or another device switch underway.
- Wanting to stop output to the previous device as soon as possible, after which the underlying device will have changed.
The promise is not resolved until an attempt to start the cubeb stream has completed, so as to provide that audio fed to the MediaStream after the promise resolves is audible in the new device, if starting the stream succeeds and the device is unmuted.
Description
•