mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Bug 1404997 - P2. Use AutoTaskQueue in VideoFrameConverter. r=pehrsons
It removes the need to explicitly shutdown the taskqueue and wait on the taskqueue to have run all dispatched task. We do want to enforce that no listeners are being called once the VideoFrameConverter's owner has been destroyed as it could potentially lead to a UAF. For now, access is okay as all operations are performed on the MSG's thread. However, this will change in follow up patches. The SourceMediaStream keeps a raw pointer to the MSG, and check if it's value isn't null to determine if the MSG has been shutdown or not, however SourceMediaStream::mGraph isn't thread safe as its access isn't protected by a mutex/monitor. MozReview-Commit-ID: 1QsJAzPuE6L --HG-- extra : rebase_source : 35f34450e62ff1f445ad6ccd06c6f6cbd3c6ed54
This commit is contained in:
parent
2fa0e45609
commit
6ae2d7162b
@ -29,6 +29,7 @@
|
||||
|
||||
#include "nsError.h"
|
||||
#include "AudioSegment.h"
|
||||
#include "AutoTaskQueue.h"
|
||||
#include "MediaSegment.h"
|
||||
#include "MediaPipelineFilter.h"
|
||||
#include "RtpLogger.h"
|
||||
@ -43,7 +44,6 @@
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
#include "mozilla/PeerIdentity.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
@ -120,6 +120,8 @@ public:
|
||||
|
||||
VideoFrameConverter()
|
||||
: mLength(0)
|
||||
, mTaskQueue(new AutoTaskQueue(
|
||||
SharedThreadPool::Get(NS_LITERAL_CSTRING("VideoFrameConverter"))))
|
||||
, last_img_(-1) // -1 is not a guaranteed invalid serial. See bug 1262134.
|
||||
#ifdef DEBUG
|
||||
, mThrottleCount(0)
|
||||
@ -128,11 +130,6 @@ public:
|
||||
, mMutex("VideoFrameConverter")
|
||||
{
|
||||
MOZ_COUNT_CTOR(VideoFrameConverter);
|
||||
|
||||
RefPtr<SharedThreadPool> pool =
|
||||
SharedThreadPool::Get(NS_LITERAL_CSTRING("VideoFrameConverter"));
|
||||
|
||||
mTaskQueue = MakeAndAddRef<TaskQueue>(pool.forget());
|
||||
}
|
||||
|
||||
void QueueVideoChunk(VideoChunk& aChunk, bool aForceBlack)
|
||||
@ -241,8 +238,8 @@ public:
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
mTaskQueue->BeginShutdown();
|
||||
mTaskQueue->AwaitShutdownAndIdle();
|
||||
MutexAutoLock lock(mMutex);
|
||||
mListeners.Clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -476,7 +473,7 @@ protected:
|
||||
}
|
||||
|
||||
Atomic<int32_t, Relaxed> mLength;
|
||||
RefPtr<TaskQueue> mTaskQueue;
|
||||
RefPtr<AutoTaskQueue> mTaskQueue;
|
||||
|
||||
// Written and read from the queueing thread (normally MSG).
|
||||
int32_t last_img_; // serial number of last Image
|
||||
|
Loading…
Reference in New Issue
Block a user