зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1163497. Part 2 - Remove MediaDecoder::DestroyDecodedStream(). r=roc.
This commit is contained in:
Родитель
61664897b5
Коммит
4db24fa288
|
@ -195,6 +195,33 @@ DecodedStream::DestroyData()
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
// Avoid the redundant blocking to output stream.
|
||||
if (!mData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// All streams are having their SourceMediaStream disconnected, so they
|
||||
// need to be explicitly blocked again.
|
||||
auto& outputStreams = OutputStreams();
|
||||
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
|
||||
OutputStreamData& os = outputStreams[i];
|
||||
// Explicitly remove all existing ports.
|
||||
// This is not strictly necessary but it's good form.
|
||||
MOZ_ASSERT(os.mPort, "Double-delete of the ports!");
|
||||
os.mPort->Destroy();
|
||||
os.mPort = nullptr;
|
||||
// During cycle collection, nsDOMMediaStream can be destroyed and send
|
||||
// its Destroy message before this decoder is destroyed. So we have to
|
||||
// be careful not to send any messages after the Destroy().
|
||||
if (os.mStream->IsDestroyed()) {
|
||||
// Probably the DOM MediaStream was GCed. Clean up.
|
||||
outputStreams.RemoveElementAt(i);
|
||||
} else {
|
||||
os.mStream->ChangeExplicitBlockerCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
mData = nullptr;
|
||||
}
|
||||
|
||||
|
@ -223,6 +250,8 @@ DecodedStream::GetReentrantMonitor()
|
|||
void
|
||||
DecodedStream::Connect(OutputStreamData* aStream)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
NS_ASSERTION(!aStream->mPort, "Already connected?");
|
||||
|
||||
// The output stream must stay in sync with the decoded stream, so if
|
||||
|
|
|
@ -303,40 +303,6 @@ void MediaDecoder::UpdateDecodedStream()
|
|||
}
|
||||
}
|
||||
|
||||
void MediaDecoder::DestroyDecodedStream()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
// Avoid the redundant blocking to output stream.
|
||||
if (!GetDecodedStream()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// All streams are having their SourceMediaStream disconnected, so they
|
||||
// need to be explicitly blocked again.
|
||||
auto& outputStreams = OutputStreams();
|
||||
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
|
||||
OutputStreamData& os = outputStreams[i];
|
||||
// Explicitly remove all existing ports.
|
||||
// This is not strictly necessary but it's good form.
|
||||
MOZ_ASSERT(os.mPort, "Double-delete of the ports!");
|
||||
os.mPort->Destroy();
|
||||
os.mPort = nullptr;
|
||||
// During cycle collection, nsDOMMediaStream can be destroyed and send
|
||||
// its Destroy message before this decoder is destroyed. So we have to
|
||||
// be careful not to send any messages after the Destroy().
|
||||
if (os.mStream->IsDestroyed()) {
|
||||
// Probably the DOM MediaStream was GCed. Clean up.
|
||||
outputStreams.RemoveElementAt(i);
|
||||
} else {
|
||||
os.mStream->ChangeExplicitBlockerCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
mDecodedStream.DestroyData();
|
||||
}
|
||||
|
||||
void MediaDecoder::UpdateStreamBlockingForStateMachinePlaying()
|
||||
{
|
||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
@ -369,8 +335,8 @@ void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs,
|
|||
if (!aGraph) {
|
||||
aGraph = GetDecodedStream()->mStream->Graph();
|
||||
}
|
||||
DestroyDecodedStream();
|
||||
|
||||
mDecodedStream.DestroyData();
|
||||
mDecodedStream.RecreateData(aStartTimeUSecs, aGraph->CreateSourceStream(nullptr));
|
||||
|
||||
// Note that the delay between removing ports in DestroyDecodedStream
|
||||
|
@ -562,7 +528,7 @@ MediaDecoder::~MediaDecoder()
|
|||
// Don't destroy the decoded stream until destructor in order to keep the
|
||||
// invariant that the decoded stream is always available in capture mode.
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
DestroyDecodedStream();
|
||||
mDecodedStream.DestroyData();
|
||||
}
|
||||
MediaMemoryTracker::RemoveMediaDecoder(this);
|
||||
UnpinForSeek();
|
||||
|
|
|
@ -397,11 +397,6 @@ public:
|
|||
|
||||
void UpdateDecodedStream();
|
||||
|
||||
/**
|
||||
* Disconnects mDecodedStream->mStream from all outputs and clears
|
||||
* mDecodedStream.
|
||||
*/
|
||||
void DestroyDecodedStream();
|
||||
/**
|
||||
* Recreates mDecodedStream. Call this to create mDecodedStream at first,
|
||||
* and when seeking, to ensure a new stream is set up with fresh buffers.
|
||||
|
|
Загрузка…
Ссылка в новой задаче