Bug 1571705 - Allow allocating an input port from a destroyed source. r=karlt

Differential Revision: https://phabricator.services.mozilla.com/D42341

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-08-19 16:53:44 +00:00
Родитель 49244b4fad
Коммит 735f1e66eb
2 изменённых файлов: 17 добавлений и 6 удалений

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

@ -2959,8 +2959,11 @@ bool SourceMediaStream::HasPendingAudioTrack() {
void MediaInputPort::Init() {
LOG(LogLevel::Debug, ("%p: Adding MediaInputPort %p (from %p to %p)",
mSource->GraphImpl(), this, mSource, mDest));
mSource->AddConsumer(this);
mDest->AddInput(this);
// Only connect the port if it wasn't disconnected on allocation.
if (mSource) {
mSource->AddConsumer(this);
mDest->AddInput(this);
}
// mPortCount decremented via MediaInputPort::Destroy's message
++mDest->GraphImpl()->mPortCount;
}
@ -3104,7 +3107,6 @@ already_AddRefed<MediaInputPort> ProcessedMediaStream::AllocateInputPort(
RefPtr<MediaInputPort> mPort;
};
MOZ_ASSERT(aStream->GraphImpl() == GraphImpl());
MOZ_ASSERT(aTrackID == TRACK_ANY || IsTrackIDExplicit(aTrackID),
"Only TRACK_ANY and explicit ID are allowed for source track");
MOZ_ASSERT(
@ -3113,8 +3115,18 @@ already_AddRefed<MediaInputPort> ProcessedMediaStream::AllocateInputPort(
MOZ_ASSERT(
aTrackID != TRACK_ANY || aDestTrackID == TRACK_ANY,
"Generic MediaInputPort cannot produce a single destination track");
RefPtr<MediaInputPort> port = new MediaInputPort(
aStream, aTrackID, this, aDestTrackID, aInputNumber, aOutputNumber);
RefPtr<MediaInputPort> port;
if (aStream->IsDestroyed()) {
// Create a port that's disconnected, which is what it'd be after its source
// stream is Destroy()ed normally. Disconnect() is idempotent so destroying
// this later is fine.
port = new MediaInputPort(nullptr, aTrackID, nullptr, aDestTrackID,
aInputNumber, aOutputNumber);
} else {
MOZ_ASSERT(aStream->GraphImpl() == GraphImpl());
port = new MediaInputPort(aStream, aTrackID, this, aDestTrackID,
aInputNumber, aOutputNumber);
}
if (aBlockedTracks) {
for (TrackID trackID : *aBlockedTracks) {
port->BlockSourceTrackIdImpl(trackID, BlockingMode::CREATION);

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

@ -604,7 +604,6 @@ already_AddRefed<MediaInputPort> MediaStreamTrack::ForwardTrackContentsTo(
ProcessedMediaStream* aStream) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(aStream);
MOZ_DIAGNOSTIC_ASSERT(!Ended());
return aStream->AllocateInputPort(mStream, mTrackID, mTrackID);
}