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:
Andreas Pehrson 2020-08-31 15:39:59 +00:00
Родитель c58d3681ed
Коммит a709257918
1 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -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);
(*entry.Data())->Destroy();
entry.Remove();
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();
}