Resume MediaTrackGraph audio when device is replugged after setSinkId()
Categories
(Core :: Audio/Video: MediaStreamGraph, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: karlt, Assigned: karlt)
References
Details
Attachments
(6 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
https://w3c.github.io/mediacapture-output/#algorithms-new-sink-available
New audio devices may become available to the user agent, or an audio device (identified by a media element's sinkId attribute) that had previously become unavailable may become available again, for example, if it is unplugged and later plugged back in.
In this scenario, the user agent must run the following steps:
- Let sinkId be the identifier for the newly available device.
- For each media element whose sinkId attribute is equal to sinkId:
- If the media element's paused attribute is false, start rendering this object's audio out of the device represented by the sinkId attribute.
STR:
- Set pref media.setsinkid.enabled true (and media.cubeb.sandbox_v2 false to workaround bug 1801049).
- Load https://bugzilla.mozilla.org/attachment.cgi?id=9303828
- Click "Go!"
- Click "Allow". (Need microphone connected.)
- Click "Default system output..."
- Select removable speaker device.
- Click "Allow".
- Remove and re-plug removable speaker device.
- Tap microphone from 4.
Expect: audio in speaker from 6.
Actual: no audio.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 1•2 years ago
•
|
||
This trace is not of the STR in comment 0, but indicates that there is an extra cubeb_stream_stop()
on destroy in the audio ipc server:
https://pernos.co/debug/m2NrySYapwiHSN-w0EuxNA/index.html#f{m[BkB4,COc_,t[kw,HQce_,f{e[BkB4,CFA_,s{af7ouQAAA,bAYw,uLrCcUg,oLrDtvA___,v[{wiLg,v[{f'list',q'stdouterr',p{_,xAYag_,{f'container',q'stack',p{_,xAYag_,{f'notebook',q'notebook',p.,xAYag___,{w/eg,v[{f'source',q'source',p{_,xAh/8_,{f'list',q'execution',p{'symbol''mozilla:3A%3AAudioStream%3A%3AStateCallback','print'':24time'_,xAYag_,{f'list',q'callees',p{_,x+mM_,{f'list',q'execution',p{'symbol''audioipc2_server:3A%3Aserver%3A%3Astate_cb_c'_,xAYag_,{f'list',q'execution',p{'symbol''cubeb_stream_stop','print'':24tid'_,x0Tk_,{f'container',q'current-tasks',p{_,xAjwG____/
This generates an extra CUBEB_STATE_STOPPED
, which would reset the Pending mAudioStreamState
before (cubeb_stream_destroy()
) it can switch to Running.
AudioCallbackDriver
is interested in state changes from only the new cubeb_stream
, not from the previous cubeb_stream
that has passed through CUBEB_STATE_ERROR
.
Assignee | ||
Comment 2•2 years ago
|
||
The extra cubeb_stream_stop()
was added to avoid UaF from callbacks after cubeb_stream_destroy()
. This notifies CUBEB_STATE_STOPPED
when done.
Assignee | ||
Comment 3•2 years ago
|
||
Such resets were preventing transitions to Running for new streams and allowing
MaybeStartAudioStream() to start another stream.
Assignee | ||
Comment 4•2 years ago
|
||
Depends on D173920
Assignee | ||
Comment 5•2 years ago
|
||
Depends on D173921
Assignee | ||
Comment 6•2 years ago
|
||
Depends on D173922
Assignee | ||
Comment 7•2 years ago
|
||
mAudioStream may be replaced on the CubebOperation thread while the fallback
driver hands over the graph to a ThreadedDriver or main thread that may create
a SHUTDOWN AsyncCubebTask.
The new assertion matches one in AudioCallbackDriver::Init() but is tested
earlier.
Depends on D173923
Assignee | ||
Comment 8•2 years ago
|
||
to save problems if/when further members are added.
cubeb_stream_user_ptr() is not used/tested right now, but this change will
make that behave as expected.
Depends on D173924
Assignee | ||
Comment 9•2 years ago
|
||
Comment 10•2 years ago
|
||
Comment 11•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/f81e1b1615b3
https://hg.mozilla.org/mozilla-central/rev/2eea0baf77ab
https://hg.mozilla.org/mozilla-central/rev/16ac83dc9ac5
https://hg.mozilla.org/mozilla-central/rev/2fafc3764c75
https://hg.mozilla.org/mozilla-central/rev/3894874ab98c
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Description
•