Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
A muted microphone track should get ended if its device disappears
https://bugs.webkit.org/show_bug.cgi?id=255591 rdar://problem/108194510 Reviewed by Eric Carlson. The main change is in BaseAudioSharedUnit::devicesChanged where we no longer exit early if the shared unit is not running. This ensures that muted tracks will be ended if their device is gone. We do a refactoring so that mock device changes kick in the BaseAudioSharedUnit::devicesChanged logic. We also do a small change to MediaStreamTrack::trackEnded to only log MediaStreamTrack capture failure if the track is not already ended. Covered by added test. Drive by fix in LayoutTests/fast/mediastream/microphone-change-while-capturing.html to ensure we use the usb fake device. Rebasing of some tests now that some additional tracks are failing due to device changes. * LayoutTests/fast/mediastream/MediaDevices-addEventListener-expected.txt: * LayoutTests/fast/mediastream/device-change-event-2-expected.txt: * LayoutTests/fast/mediastream/microphone-change-while-capturing-expected.txt: * LayoutTests/fast/mediastream/microphone-change-while-capturing.html: * LayoutTests/fast/mediastream/microphone-change-while-muted-expected.txt: Added. * LayoutTests/fast/mediastream/microphone-change-while-muted.html: Copied from LayoutTests/fast/mediastream/microphone-change-while-capturing.html. * LayoutTests/platform/glib/TestExpectations: * Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::trackEnded): * Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp: (WebCore::BaseAudioSharedUnit::BaseAudioSharedUnit): (WebCore::BaseAudioSharedUnit::~BaseAudioSharedUnit): (WebCore::BaseAudioSharedUnit::devicesChanged): * Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h: * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp: (WebCore::CoreAudioCaptureDeviceManager::refreshAudioCaptureDevices): * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSourceFactory::devicesChanged): Deleted. * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h: Canonical link: https://commits.webkit.org/263132@main
- Loading branch information
Showing
13 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
LayoutTests/fast/mediastream/MediaDevices-addEventListener-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
LayoutTests/fast/mediastream/device-change-event-2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
LayoutTests/fast/mediastream/microphone-change-while-capturing-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
LayoutTests/fast/mediastream/microphone-change-while-muted-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure | ||
|
||
|
||
PASS Detection of missing capturing device should trigger capture to fail even if track is muted | ||
|
56 changes: 56 additions & 0 deletions
56
LayoutTests/fast/mediastream/microphone-change-while-muted.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Testing change of device while capturing.</title> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id="video"></video> | ||
<script> | ||
let setup = async (test) => { | ||
if (!window.testRunner) | ||
return Promise.reject("test requires internal API"); | ||
|
||
test.add_cleanup(() => { testRunner.resetMockMediaDevices(); }); | ||
} | ||
|
||
async function getDeviceId(label) | ||
{ | ||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | ||
const devices = await navigator.mediaDevices.enumerateDevices(); | ||
let deviceId; | ||
devices.forEach(device => { | ||
if (device.label === "my USB microphone") | ||
deviceId = device.deviceId; | ||
}); | ||
|
||
stream.getAudioTracks()[0].stop(); | ||
|
||
return deviceId; | ||
} | ||
|
||
promise_test(async (test) => { | ||
await setup(test); | ||
|
||
testRunner.addMockMicrophoneDevice("usbmic", "my USB microphone"); | ||
|
||
const deviceId = await getDeviceId("my USB microphone"); | ||
video.srcObject = await navigator.mediaDevices.getUserMedia({ audio: { deviceId } }); | ||
await video.play(); | ||
|
||
if (window.internals) | ||
internals.setPageMuted("capturedevices"); | ||
|
||
await new Promise(resolve => video.srcObject.getAudioTracks()[0].onmute = resolve); | ||
|
||
testRunner.removeMockMediaDevice("usbmic"); | ||
return new Promise((resolve, reject) => { | ||
video.srcObject.getAudioTracks()[0].onended = resolve; | ||
setTimeout(() => reject("track did not end"), 2000); | ||
}); | ||
}, "Detection of missing capturing device should trigger capture to fail even if track is muted"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters