Bug 1203449 - Remove OutputStreamListener from DecodedStream.cpp. r=roc.

This commit is contained in:
JW Wang 2015-09-14 10:43:27 +08:00
Родитель 539b180951
Коммит 962c356c98
2 изменённых файлов: 0 добавлений и 53 удалений

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

@ -193,44 +193,9 @@ DecodedStreamData::SetPlaying(bool aPlaying)
}
}
class OutputStreamListener : public MediaStreamListener {
typedef MediaStreamListener::MediaStreamGraphEvent MediaStreamGraphEvent;
public:
explicit OutputStreamListener(OutputStreamData* aOwner) : mOwner(aOwner) {}
void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamGraphEvent event) override
{
if (event == EVENT_FINISHED) {
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
this, &OutputStreamListener::DoNotifyFinished);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(r.forget());
}
}
void Forget()
{
MOZ_ASSERT(NS_IsMainThread());
mOwner = nullptr;
}
private:
void DoNotifyFinished()
{
MOZ_ASSERT(NS_IsMainThread());
if (mOwner) {
// Remove the finished stream so it won't block the decoded stream.
mOwner->Remove();
}
}
// Main thread only
OutputStreamData* mOwner;
};
OutputStreamData::~OutputStreamData()
{
MOZ_ASSERT(NS_IsMainThread());
mListener->Forget();
// Break the connection to the input stream if necessary.
if (mPort) {
mPort->Destroy();
@ -242,8 +207,6 @@ OutputStreamData::Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStrea
{
mOwner = aOwner;
mStream = aStream;
mListener = new OutputStreamListener(this);
aStream->AddListener(mListener);
}
void
@ -282,13 +245,6 @@ OutputStreamData::Disconnect()
return true;
}
void
OutputStreamData::Remove()
{
MOZ_ASSERT(NS_IsMainThread());
mOwner->Remove(mStream);
}
MediaStreamGraph*
OutputStreamData::Graph() const
{

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

@ -26,17 +26,12 @@ class MediaData;
class MediaInputPort;
class MediaStream;
class MediaStreamGraph;
class OutputStreamListener;
class OutputStreamManager;
class ProcessedMediaStream;
class TimeStamp;
template <class T> class MediaQueue;
namespace layers {
class Image;
} // namespace layers
class OutputStreamData {
public:
~OutputStreamData();
@ -47,9 +42,6 @@ public:
// Disconnect mStream from its input stream.
// Return false is mStream is already destroyed, otherwise true.
bool Disconnect();
// Called by OutputStreamListener to remove self from the output streams
// managed by OutputStreamManager.
void Remove();
// Return true if aStream points to the same object as mStream.
// Used by OutputStreamManager to remove an output stream.
bool Equals(MediaStream* aStream)
@ -64,7 +56,6 @@ private:
nsRefPtr<ProcessedMediaStream> mStream;
// mPort connects our mStream to an input stream.
nsRefPtr<MediaInputPort> mPort;
nsRefPtr<OutputStreamListener> mListener;
};
class OutputStreamManager {