Bug 1319992: P4. Use Mutex in place of Monitor. r=jwwang
MozReview-Commit-ID: 79z6EtZQhYu
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -14,17 +14,16 @@
#include "VideoUtils.h"
#include "VideoFrameContainer.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
-#include "mozilla/Mutex.h"
#include "mozilla/SharedThreadPool.h"
#include "mozilla/SyncRunnable.h"
#include "nsContentUtils.h"
#include "nsPrintfCString.h"
#include "nsSize.h"
#include <algorithm>
#include <queue>
@@ -410,17 +409,17 @@ MediaFormatReader::DecoderFactory::DoIni
auto& ownerData = mOwner->GetDecoderData(aTrack);
auto& data = aTrack == TrackInfo::kAudioTrack ? mAudio : mVideo;
data.mInitPromise.Begin(data.mDecoder->Init()->Then(
mOwner->OwnerThread(), __func__,
[this, &data, &ownerData] (TrackType aTrack) {
data.mInitPromise.Complete();
data.mStage = Stage::None;
- MonitorAutoLock mon(ownerData.mMonitor);
+ MutexAutoLock lock(ownerData.mMutex);
ownerData.mDecoder = data.mDecoder.forget();
ownerData.mDescription = ownerData.mDecoder->GetDescriptionName();
mOwner->SetVideoDecodeThreshold();
mOwner->ScheduleUpdate(aTrack);
},
[this, &data, aTrack] (MediaResult aError) {
data.mInitPromise.Complete();
data.mStage = Stage::None;
@@ -2651,21 +2650,21 @@ MediaFormatReader::GetImageContainer()
void
MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
{
nsAutoCString result;
const char* audioName = "unavailable";
const char* videoName = audioName;
if (HasAudio()) {
- MonitorAutoLock mon(mAudio.mMonitor);
+ MutexAutoLock lock(mAudio.mMutex);
audioName = mAudio.mDescription;
}
if (HasVideo()) {
- MonitorAutoLock mon(mVideo.mMonitor);
+ MutexAutoLock mon(mVideo.mMutex);
videoName = mVideo.mDescription;
}
result += nsPrintfCString("audio decoder: %s\n", audioName);
result += nsPrintfCString("audio frames decoded: %lld\n",
mAudio.mNumSamplesOutputTotal);
if (HasAudio()) {
result += nsPrintfCString("audio state: ni=%d no=%d ie=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu out:%llu qs=%u pending:%u waiting:%d wfk:%d sid:%u\n",
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -5,17 +5,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(MediaFormatReader_h_)
#define MediaFormatReader_h_
#include "mozilla/Atomics.h"
#include "mozilla/Maybe.h"
#include "mozilla/TaskQueue.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/Mutex.h"
#include "MediaEventSource.h"
#include "MediaDataDemuxer.h"
#include "MediaDecoderReader.h"
#include "nsAutoPtr.h"
#include "PDMFactory.h"
namespace mozilla {
@@ -204,17 +204,17 @@ private:
};
struct DecoderData {
DecoderData(MediaFormatReader* aOwner,
MediaData::Type aType,
uint32_t aNumOfMaxError)
: mOwner(aOwner)
, mType(aType)
- , mMonitor("DecoderData")
+ , mMutex("DecoderData")
, mDescription("shutdown")
, mUpdateScheduled(false)
, mDemuxEOS(false)
, mWaitingForData(false)
, mWaitingForKey(false)
, mReceivedNewData(false)
, mOutputRequested(false)
, mDecodePending(false)
@@ -238,24 +238,24 @@ private:
MediaData::Type mType;
RefPtr<MediaTrackDemuxer> mTrackDemuxer;
// TaskQueue on which decoder can choose to decode.
// Only non-null up until the decoder is created.
RefPtr<TaskQueue> mTaskQueue;
// Callback that receives output and error notifications from the decoder.
nsAutoPtr<DecoderCallback> mCallback;
- // Monitor protecting mDescription and mDecoder.
- Monitor mMonitor;
+ // Mutex protecting mDescription and mDecoder.
+ Mutex mMutex;
// The platform decoder.
RefPtr<MediaDataDecoder> mDecoder;
const char* mDescription;
void ShutdownDecoder()
{
- MonitorAutoLock mon(mMonitor);
+ MutexAutoLock lock(mMutex);
if (mDecoder) {
mDecoder->Shutdown();
}
mDescription = "shutdown";
mDecoder = nullptr;
}
// Only accessed from reader's task queue.