commit 930fdb3e1893ec57f758cd921dcb4beff2c7d2fa
parent f7abca3366ee73d9bad3dbcfb93571a9b1fa447f
Author: John Lin <jolin@mozilla.com>
Date: Tue, 2 Dec 2025 18:37:37 +0000
Bug 1999591 - protect shared codec buffer callback. r=media-playback-reviewers,aosmond
Differential Revision: https://phabricator.services.mozilla.com/D274164
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -20,6 +20,7 @@
#include "VPXDecoder.h"
#include "VideoUtils.h"
#include "mozilla/Maybe.h"
+#include "mozilla/Mutex.h"
#include "mozilla/fallible.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/Types.h"
@@ -49,12 +50,15 @@ class RenderOrReleaseOutput {
public:
RenderOrReleaseOutput(java::CodecProxy::Param aCodec,
java::Sample::Param aSample)
- : mCodec(aCodec), mSample(aSample) {}
+ : mMutex("AndroidRenderOrReleaseOutput"),
+ mCodec(aCodec),
+ mSample(aSample) {}
virtual ~RenderOrReleaseOutput() { ReleaseOutput(false); }
protected:
void ReleaseOutput(bool aToRender) {
+ MutexAutoLock lock(mMutex);
if (mCodec && mSample) {
mCodec->ReleaseOutput(mSample, aToRender);
mCodec = nullptr;
@@ -63,8 +67,9 @@ class RenderOrReleaseOutput {
}
private:
- java::CodecProxy::GlobalRef mCodec;
- java::Sample::GlobalRef mSample;
+ Mutex mMutex;
+ java::CodecProxy::GlobalRef mCodec MOZ_GUARDED_BY(mMutex);
+ java::Sample::GlobalRef mSample MOZ_GUARDED_BY(mMutex);
};
static bool areSmpte432ColorPrimariesBuggy() {