Bug 1786306 Destroy() associated MediaTracks and MediaInputPort in CrossGraphPort destructor r=padenot

`MediaTrack`s, such as `CrossGraphTransmitter` and `CrossGraphReceiver`, and
`MediaInputPort`s need to be explicitly destroyed.
https://searchfox.org/mozilla-central/rev/52da19becaa3805e7f64088e91e9dade7dec43c8/dom/media/MediaTrackGraph.h#213-216,779-783

`CrossGraphPort` is not reference counted and so it does not need a
`Destroy()` method.

`~AudioStreamTrack` did not call `Destroy()` on its `CrossGraphPort`s from its
destructor, which could leak the `CrossGraphPort`s' tracks and ports.

Differential Revision: https://phabricator.services.mozilla.com/D158309
This commit is contained in:
Karl Tomlinson 2022-09-30 04:13:34 +00:00
Родитель 67e1a4f489
Коммит c61cd6d03d
3 изменённых файлов: 2 добавлений и 7 удалений

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

@ -28,7 +28,6 @@ void AudioStreamTrack::RemoveAudioOutput(void* aKey) {
if (auto entry = mCrossGraphs.Lookup(aKey)) {
// The audio output for this track is directed to a non-default device.
// The CrossGraphPort for this output is no longer required so remove it.
entry.Data()->Destroy();
entry.Remove();
return;
}
@ -63,9 +62,6 @@ void AudioStreamTrack::SetReadyState(MediaStreamTrackState aState) {
if (!mCrossGraphs.IsEmpty() && !Ended() &&
mReadyState == MediaStreamTrackState::Live &&
aState == MediaStreamTrackState::Ended) {
for (const auto& data : mCrossGraphs.Values()) {
data->Destroy();
}
mCrossGraphs.Clear();
}
MediaStreamTrack::SetReadyState(aState);

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

@ -81,7 +81,7 @@ void CrossGraphPort::SetAudioOutputVolume(void* aKey, float aVolume) {
mReceiver->SetAudioOutputVolume(aKey, aVolume);
}
void CrossGraphPort::Destroy() {
CrossGraphPort::~CrossGraphPort() {
mTransmitter->Destroy();
mReceiver->Destroy();
mTransmitterPort->Destroy();

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

@ -73,12 +73,11 @@ class CrossGraphPort final {
static UniquePtr<CrossGraphPort> Connect(
const RefPtr<dom::AudioStreamTrack>& aStreamTrack, AudioDeviceInfo* aSink,
nsPIDOMWindowInner* aWindow);
~CrossGraphPort() = default;
~CrossGraphPort();
void AddAudioOutput(void* aKey);
void RemoveAudioOutput(void* aKey);
void SetAudioOutputVolume(void* aKey, float aVolume);
void Destroy();
RefPtr<GenericPromise> EnsureConnected();