зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1661649 - Allow re-setting the default output device for a key on AudioStreamTrack. r=padenot
Depends on D88825 Differential Revision: https://phabricator.services.mozilla.com/D88826
This commit is contained in:
Родитель
c58d3681ed
Коммит
a709257918
|
@ -73,22 +73,32 @@ void AudioStreamTrack::SetReadyState(MediaStreamTrackState aState) {
|
|||
RefPtr<GenericPromise> AudioStreamTrack::SetAudioOutputDevice(
|
||||
void* key, AudioDeviceInfo* aSink) {
|
||||
MOZ_ASSERT(aSink);
|
||||
|
||||
if (Ended()) {
|
||||
return GenericPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
UniquePtr<CrossGraphPort> manager =
|
||||
CrossGraphPort::Connect(this, aSink, mWindow);
|
||||
if (!manager) {
|
||||
// We are setting the default output device.
|
||||
auto entry = mCrossGraphs.Lookup(key);
|
||||
MOZ_ASSERT(entry);
|
||||
if (entry) {
|
||||
// There is an existing non-default output device for this track. Remove
|
||||
// it.
|
||||
(*entry.Data())->Destroy();
|
||||
entry.Remove();
|
||||
}
|
||||
return GenericPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
// We are setting a non-default output device.
|
||||
UniquePtr<CrossGraphPort>& crossGraphPtr = *mCrossGraphs.LookupOrAdd(key);
|
||||
if (crossGraphPtr) {
|
||||
// This key already has a non-default output device set. Destroy it.
|
||||
crossGraphPtr->Destroy();
|
||||
}
|
||||
|
||||
crossGraphPtr = std::move(manager);
|
||||
return crossGraphPtr->EnsureConnected();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче