|
@@ -0,0 +1,1118 @@
|
|
|
|
+# HG changeset patch
|
|
|
|
+# User Mike Hommey <mh+mozilla@glandium.org>
|
|
|
|
+# Date 1646108126 0
|
|
|
|
+# Node ID 145ea24af3f1a54da30fd38e3828f6648b89f52f
|
|
|
|
+# Parent bcaf12cff4db3d495fdfdc24c1ba67f21a26b782
|
|
|
|
+Bug 1757122 - Replace unqualified uses of std::move. r=xpcom-reviewers,media-playback-reviewers,mccr8,bryce
|
|
|
|
+
|
|
|
|
+Clang trunk added a warning about unqualified uses of std::move.
|
|
|
|
+https://reviews.llvm.org/D119670
|
|
|
|
+
|
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D139681
|
|
|
|
+
|
|
|
|
+diff --git a/dom/media/MediaTrackGraph.cpp.1757122.later b/dom/media/MediaTrackGraph.cpp.1757122.later
|
|
|
|
+new file mode 100644
|
|
|
|
+--- /dev/null
|
|
|
|
++++ b/dom/media/MediaTrackGraph.cpp.1757122.later
|
|
|
|
+@@ -0,0 +1,430 @@
|
|
|
|
++--- MediaTrackGraph.cpp
|
|
|
|
+++++ MediaTrackGraph.cpp
|
|
|
|
++@@ -39,17 +39,16 @@
|
|
|
|
++ #include "Tracing.h"
|
|
|
|
++ #include "UnderrunHandler.h"
|
|
|
|
++ #include "mozilla/CycleCollectedJSRuntime.h"
|
|
|
|
++ #include "mozilla/Preferences.h"
|
|
|
|
++
|
|
|
|
++ #include "webaudio/blink/DenormalDisabler.h"
|
|
|
|
++ #include "webaudio/blink/HRTFDatabaseLoader.h"
|
|
|
|
++
|
|
|
|
++-using std::move;
|
|
|
|
++ using namespace mozilla::layers;
|
|
|
|
++ using namespace mozilla::dom;
|
|
|
|
++ using namespace mozilla::gfx;
|
|
|
|
++ using namespace mozilla::media;
|
|
|
|
++
|
|
|
|
++ namespace mozilla {
|
|
|
|
++
|
|
|
|
++ LazyLogModule gMediaTrackGraphLog("MediaTrackGraph");
|
|
|
|
++@@ -876,17 +875,17 @@ void MediaTrackGraphImpl::DeviceChanged(
|
|
|
|
++ MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
++ mAudioOutputLatency = 0.0;
|
|
|
|
++
|
|
|
|
++ // Dispatch to the bg thread to do the (potentially expensive) query of the
|
|
|
|
++ // maximum channel count, and then dispatch back to the main thread, then to
|
|
|
|
++ // the graph, with the new info.
|
|
|
|
++ RefPtr<MediaTrackGraphImpl> self = this;
|
|
|
|
++ NS_DispatchBackgroundTask(NS_NewRunnableFunction(
|
|
|
|
++- "MaxChannelCountUpdateOnBgThread", [self{move(self)}]() {
|
|
|
|
+++ "MaxChannelCountUpdateOnBgThread", [self{std::move(self)}]() {
|
|
|
|
++ uint32_t maxChannelCount = CubebUtils::MaxNumberOfChannels();
|
|
|
|
++ self->Dispatch(NS_NewRunnableFunction(
|
|
|
|
++ "MaxChannelCountUpdateToMainThread",
|
|
|
|
++ [self{self}, maxChannelCount]() {
|
|
|
|
++ class MessageToGraph : public ControlMessage {
|
|
|
|
++ public:
|
|
|
|
++ explicit MessageToGraph(MediaTrackGraph* aGraph,
|
|
|
|
++ uint32_t aMaxChannelCount)
|
|
|
|
++@@ -1010,17 +1009,17 @@ void MediaTrackGraphImpl::PrepareUpdates
|
|
|
|
++ // tracks that are removed from the graph.
|
|
|
|
++ MOZ_ASSERT(!track || track->GraphImpl() == this);
|
|
|
|
++ if (!track || track->MainThreadNeedsUpdates()) {
|
|
|
|
++ // Discard this update as it has either been cleared when the track
|
|
|
|
++ // was destroyed or there will be a newer update below.
|
|
|
|
++ continue;
|
|
|
|
++ }
|
|
|
|
++ if (keptUpdateCount != i) {
|
|
|
|
++- mTrackUpdates[keptUpdateCount] = move(mTrackUpdates[i]);
|
|
|
|
+++ mTrackUpdates[keptUpdateCount] = std::move(mTrackUpdates[i]);
|
|
|
|
++ MOZ_ASSERT(!mTrackUpdates[i].mTrack);
|
|
|
|
++ }
|
|
|
|
++ ++keptUpdateCount;
|
|
|
|
++ }
|
|
|
|
++ mTrackUpdates.TruncateLength(keptUpdateCount);
|
|
|
|
++
|
|
|
|
++ mTrackUpdates.SetCapacity(mTrackUpdates.Length() + mTracks.Length() +
|
|
|
|
++ mSuspendedTracks.Length());
|
|
|
|
++@@ -1033,17 +1032,17 @@ void MediaTrackGraphImpl::PrepareUpdates
|
|
|
|
++ // No blocking to worry about here, since we've passed
|
|
|
|
++ // UpdateCurrentTimeForTracks.
|
|
|
|
++ update->mNextMainThreadCurrentTime =
|
|
|
|
++ track->GraphTimeToTrackTime(mProcessedTime);
|
|
|
|
++ update->mNextMainThreadEnded = track->mNotifiedEnded;
|
|
|
|
++ }
|
|
|
|
++ mNextMainThreadGraphTime = mProcessedTime;
|
|
|
|
++ if (!mPendingUpdateRunnables.IsEmpty()) {
|
|
|
|
++- mUpdateRunnables.AppendElements(move(mPendingUpdateRunnables));
|
|
|
|
+++ mUpdateRunnables.AppendElements(std::move(mPendingUpdateRunnables));
|
|
|
|
++ }
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ // If this is the final update, then a stable state event will soon be
|
|
|
|
++ // posted just before this thread finishes, and so there is no need to also
|
|
|
|
++ // post here.
|
|
|
|
++ if (!aFinalUpdate &&
|
|
|
|
++ // Don't send the message to the main thread if it's not going to have
|
|
|
|
++@@ -1102,17 +1101,17 @@ void MediaTrackGraphImpl::RunMessageAfte
|
|
|
|
++ MOZ_ASSERT(OnGraphThread());
|
|
|
|
++
|
|
|
|
++ if (mFrontMessageQueue.IsEmpty()) {
|
|
|
|
++ mFrontMessageQueue.AppendElement();
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ // Only one block is used for messages from the graph thread.
|
|
|
|
++ MOZ_ASSERT(mFrontMessageQueue.Length() == 1);
|
|
|
|
++- mFrontMessageQueue[0].mMessages.AppendElement(move(aMessage));
|
|
|
|
+++ mFrontMessageQueue[0].mMessages.AppendElement(std::move(aMessage));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraphImpl::RunMessagesInQueue() {
|
|
|
|
++ TRACE("MTG::RunMessagesInQueue");
|
|
|
|
++ MOZ_ASSERT(OnGraphThread());
|
|
|
|
++ // Calculate independent action times for each batch of messages (each
|
|
|
|
++ // batch corresponding to an event loop task). This isolates the performance
|
|
|
|
++ // of different scripts to some extent.
|
|
|
|
++@@ -1399,17 +1398,17 @@ auto MediaTrackGraphImpl::OneIterationIm
|
|
|
|
++ SwitchAtNextIteration(nullptr);
|
|
|
|
++ }
|
|
|
|
++ return IterationResult::CreateStop(
|
|
|
|
++ NewRunnableMethod("MediaTrackGraphImpl::SignalMainThreadCleanup", this,
|
|
|
|
++ &MediaTrackGraphImpl::SignalMainThreadCleanup));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ if (Switching()) {
|
|
|
|
++- RefPtr<GraphDriver> nextDriver = move(mNextDriver);
|
|
|
|
+++ RefPtr<GraphDriver> nextDriver = std::move(mNextDriver);
|
|
|
|
++ return IterationResult::CreateSwitchDriver(
|
|
|
|
++ nextDriver, NewRunnableMethod<StoreRefPtrPassByPtr<GraphDriver>>(
|
|
|
|
++ "MediaTrackGraphImpl::SetCurrentDriver", this,
|
|
|
|
++ &MediaTrackGraphImpl::SetCurrentDriver, nextDriver));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ return IterationResult::CreateStillProcessing();
|
|
|
|
++ }
|
|
|
|
++@@ -1763,17 +1762,18 @@ void MediaTrackGraphImpl::RunInStableSta
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ if (LifecycleStateRef() == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP &&
|
|
|
|
++ mForceShutDownReceived) {
|
|
|
|
++ // Defer calls to RunDuringShutdown() to happen while mMonitor is not
|
|
|
|
++ // held.
|
|
|
|
++ for (uint32_t i = 0; i < mBackMessageQueue.Length(); ++i) {
|
|
|
|
++ MessageBlock& mb = mBackMessageQueue[i];
|
|
|
|
++- controlMessagesToRunDuringShutdown.AppendElements(move(mb.mMessages));
|
|
|
|
+++ controlMessagesToRunDuringShutdown.AppendElements(
|
|
|
|
+++ std::move(mb.mMessages));
|
|
|
|
++ }
|
|
|
|
++ mBackMessageQueue.Clear();
|
|
|
|
++ MOZ_ASSERT(mCurrentTaskMessageQueue.IsEmpty());
|
|
|
|
++ // Stop MediaTrackGraph threads.
|
|
|
|
++ LifecycleStateRef() = LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN;
|
|
|
|
++ nsCOMPtr<nsIRunnable> event = new MediaTrackGraphShutDownRunnable(this);
|
|
|
|
++ mMainThread->Dispatch(event.forget());
|
|
|
|
++ }
|
|
|
|
++@@ -1860,22 +1860,22 @@ void MediaTrackGraphImpl::AppendMessage(
|
|
|
|
++ #endif
|
|
|
|
++ if (IsEmpty() &&
|
|
|
|
++ LifecycleStateRef() >= LIFECYCLE_WAITING_FOR_TRACK_DESTRUCTION) {
|
|
|
|
++ Destroy();
|
|
|
|
++ }
|
|
|
|
++ return;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++- mCurrentTaskMessageQueue.AppendElement(move(aMessage));
|
|
|
|
+++ mCurrentTaskMessageQueue.AppendElement(std::move(aMessage));
|
|
|
|
++ EnsureRunInStableState();
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraphImpl::Dispatch(already_AddRefed<nsIRunnable>&& aRunnable) {
|
|
|
|
++- mMainThread->Dispatch(move(aRunnable));
|
|
|
|
+++ mMainThread->Dispatch(std::move(aRunnable));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ MediaTrack::MediaTrack(TrackRate aSampleRate, MediaSegment::Type aType,
|
|
|
|
++ MediaSegment* aSegment)
|
|
|
|
++ : mSampleRate(aSampleRate),
|
|
|
|
++ mType(aType),
|
|
|
|
++ mSegment(aSegment),
|
|
|
|
++ mStartTime(0),
|
|
|
|
++@@ -2168,17 +2168,17 @@ void MediaTrack::Resume() {
|
|
|
|
++ return;
|
|
|
|
++ }
|
|
|
|
++ GraphImpl()->AppendMessage(MakeUnique<Message>(this));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrack::AddListenerImpl(
|
|
|
|
++ already_AddRefed<MediaTrackListener> aListener) {
|
|
|
|
++ RefPtr<MediaTrackListener> l(aListener);
|
|
|
|
++- mTrackListeners.AppendElement(move(l));
|
|
|
|
+++ mTrackListeners.AppendElement(std::move(l));
|
|
|
|
++
|
|
|
|
++ PrincipalHandle lastPrincipalHandle = mSegment->GetLastPrincipalHandle();
|
|
|
|
++ mTrackListeners.LastElement()->NotifyPrincipalHandleChanged(
|
|
|
|
++ Graph(), lastPrincipalHandle);
|
|
|
|
++ if (mNotifiedEnded) {
|
|
|
|
++ mTrackListeners.LastElement()->NotifyEnded(Graph());
|
|
|
|
++ }
|
|
|
|
++ if (CombinedDisabledMode() == DisabledTrackMode::SILENCE_BLACK) {
|
|
|
|
++@@ -2235,17 +2235,17 @@ RefPtr<GenericPromise> MediaTrack::Remov
|
|
|
|
++ };
|
|
|
|
++
|
|
|
|
++ UniquePtr<Message> message = MakeUnique<Message>(this, aListener);
|
|
|
|
++ RefPtr<GenericPromise> p = message->mRemovedPromise.Ensure(__func__);
|
|
|
|
++ if (mMainThreadDestroyed) {
|
|
|
|
++ message->mRemovedPromise.Reject(NS_ERROR_FAILURE, __func__);
|
|
|
|
++ return p;
|
|
|
|
++ }
|
|
|
|
++- GraphImpl()->AppendMessage(move(message));
|
|
|
|
+++ GraphImpl()->AppendMessage(std::move(message));
|
|
|
|
++ return p;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrack::AddDirectListenerImpl(
|
|
|
|
++ already_AddRefed<DirectMediaTrackListener> aListener) {
|
|
|
|
++ // Base implementation, for tracks that don't support direct track listeners.
|
|
|
|
++ RefPtr<DirectMediaTrackListener> listener = aListener;
|
|
|
|
++ listener->NotifyDirectListenerInstalled(
|
|
|
|
++@@ -3295,34 +3295,34 @@ void MediaTrackGraphImpl::CollectSizesFo
|
|
|
|
++ already_AddRefed<nsISupports> aHandlerData)
|
|
|
|
++ : mozilla::Runnable("FinishCollectRunnable"),
|
|
|
|
++ mHandleReport(aHandleReport),
|
|
|
|
++ mHandlerData(aHandlerData) {}
|
|
|
|
++
|
|
|
|
++ NS_IMETHOD Run() override {
|
|
|
|
++ TRACE("MTG::FinishCollectReports ControlMessage");
|
|
|
|
++ MediaTrackGraphImpl::FinishCollectReports(mHandleReport, mHandlerData,
|
|
|
|
++- move(mAudioTrackSizes));
|
|
|
|
+++ std::move(mAudioTrackSizes));
|
|
|
|
++ return NS_OK;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ nsTArray<AudioNodeSizes> mAudioTrackSizes;
|
|
|
|
++
|
|
|
|
++ private:
|
|
|
|
++ ~FinishCollectRunnable() = default;
|
|
|
|
++
|
|
|
|
++ // Avoiding nsCOMPtr because NSCAP_ASSERT_NO_QUERY_NEEDED in its
|
|
|
|
++ // constructor modifies the ref-count, which cannot be done off main
|
|
|
|
++ // thread.
|
|
|
|
++ RefPtr<nsIHandleReportCallback> mHandleReport;
|
|
|
|
++ RefPtr<nsISupports> mHandlerData;
|
|
|
|
++ };
|
|
|
|
++
|
|
|
|
++- RefPtr<FinishCollectRunnable> runnable =
|
|
|
|
++- new FinishCollectRunnable(move(aHandleReport), move(aHandlerData));
|
|
|
|
+++ RefPtr<FinishCollectRunnable> runnable = new FinishCollectRunnable(
|
|
|
|
+++ std::move(aHandleReport), std::move(aHandlerData));
|
|
|
|
++
|
|
|
|
++ auto audioTrackSizes = &runnable->mAudioTrackSizes;
|
|
|
|
++
|
|
|
|
++ for (MediaTrack* t : AllTracks()) {
|
|
|
|
++ AudioNodeTrack* track = t->AsAudioNodeTrack();
|
|
|
|
++ if (track) {
|
|
|
|
++ AudioNodeSizes* usage = audioTrackSizes->AppendElement();
|
|
|
|
++ track->SizeOfAudioNodesIncludingThis(MallocSizeOf, *usage);
|
|
|
|
++@@ -3449,88 +3449,88 @@ void MediaTrackGraphImpl::RemoveTrack(Me
|
|
|
|
++ }
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ auto MediaTrackGraph::NotifyWhenDeviceStarted(MediaTrack* aTrack)
|
|
|
|
++ -> RefPtr<GraphStartedPromise> {
|
|
|
|
++ MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
++ MozPromiseHolder<GraphStartedPromise> h;
|
|
|
|
++ RefPtr<GraphStartedPromise> p = h.Ensure(__func__);
|
|
|
|
++- aTrack->GraphImpl()->NotifyWhenGraphStarted(aTrack, move(h));
|
|
|
|
+++ aTrack->GraphImpl()->NotifyWhenGraphStarted(aTrack, std::move(h));
|
|
|
|
++ return p;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraphImpl::NotifyWhenGraphStarted(
|
|
|
|
++ RefPtr<MediaTrack> aTrack,
|
|
|
|
++ MozPromiseHolder<GraphStartedPromise>&& aHolder) {
|
|
|
|
++ class GraphStartedNotificationControlMessage : public ControlMessage {
|
|
|
|
++ RefPtr<MediaTrack> mMediaTrack;
|
|
|
|
++ MozPromiseHolder<GraphStartedPromise> mHolder;
|
|
|
|
++
|
|
|
|
++ public:
|
|
|
|
++ GraphStartedNotificationControlMessage(
|
|
|
|
++ RefPtr<MediaTrack> aTrack,
|
|
|
|
++ MozPromiseHolder<GraphStartedPromise>&& aHolder)
|
|
|
|
++ : ControlMessage(nullptr),
|
|
|
|
++- mMediaTrack(move(aTrack)),
|
|
|
|
++- mHolder(move(aHolder)) {}
|
|
|
|
+++ mMediaTrack(std::move(aTrack)),
|
|
|
|
+++ mHolder(std::move(aHolder)) {}
|
|
|
|
++ void Run() override {
|
|
|
|
++ TRACE("MTG::GraphStartedNotificationControlMessage ControlMessage");
|
|
|
|
++ // This runs on the graph thread, so when this runs, and the current
|
|
|
|
++ // driver is an AudioCallbackDriver, we know the audio hardware is
|
|
|
|
++ // started. If not, we are going to switch soon, keep reposting this
|
|
|
|
++ // ControlMessage.
|
|
|
|
++ MediaTrackGraphImpl* graphImpl = mMediaTrack->GraphImpl();
|
|
|
|
++ if (graphImpl->CurrentDriver()->AsAudioCallbackDriver() &&
|
|
|
|
++ graphImpl->CurrentDriver()->ThreadRunning() &&
|
|
|
|
++ !graphImpl->CurrentDriver()->AsAudioCallbackDriver()->OnFallback()) {
|
|
|
|
++ // Avoid Resolve's locking on the graph thread by doing it on main.
|
|
|
|
++ graphImpl->Dispatch(NS_NewRunnableFunction(
|
|
|
|
++ "MediaTrackGraphImpl::NotifyWhenGraphStarted::Resolver",
|
|
|
|
++- [holder = move(mHolder)]() mutable {
|
|
|
|
+++ [holder = std::move(mHolder)]() mutable {
|
|
|
|
++ holder.Resolve(true, __func__);
|
|
|
|
++ }));
|
|
|
|
++ } else {
|
|
|
|
++ graphImpl->DispatchToMainThreadStableState(
|
|
|
|
++ NewRunnableMethod<
|
|
|
|
++ StoreCopyPassByRRef<RefPtr<MediaTrack>>,
|
|
|
|
++ StoreCopyPassByRRef<MozPromiseHolder<GraphStartedPromise>>>(
|
|
|
|
++ "MediaTrackGraphImpl::NotifyWhenGraphStarted", graphImpl,
|
|
|
|
++- &MediaTrackGraphImpl::NotifyWhenGraphStarted, move(mMediaTrack),
|
|
|
|
++- move(mHolder)));
|
|
|
|
+++ &MediaTrackGraphImpl::NotifyWhenGraphStarted,
|
|
|
|
+++ std::move(mMediaTrack), std::move(mHolder)));
|
|
|
|
++ }
|
|
|
|
++ }
|
|
|
|
++ void RunDuringShutdown() override {
|
|
|
|
++ mHolder.Reject(NS_ERROR_ILLEGAL_DURING_SHUTDOWN, __func__);
|
|
|
|
++ }
|
|
|
|
++ };
|
|
|
|
++
|
|
|
|
++ if (aTrack->IsDestroyed()) {
|
|
|
|
++ aHolder.Reject(NS_ERROR_NOT_AVAILABLE, __func__);
|
|
|
|
++ return;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ MediaTrackGraphImpl* graph = aTrack->GraphImpl();
|
|
|
|
++ graph->AppendMessage(MakeUnique<GraphStartedNotificationControlMessage>(
|
|
|
|
++- move(aTrack), move(aHolder)));
|
|
|
|
+++ std::move(aTrack), std::move(aHolder)));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ class AudioContextOperationControlMessage : public ControlMessage {
|
|
|
|
++ using AudioContextOperationPromise =
|
|
|
|
++ MediaTrackGraph::AudioContextOperationPromise;
|
|
|
|
++
|
|
|
|
++ public:
|
|
|
|
++ AudioContextOperationControlMessage(
|
|
|
|
++ MediaTrack* aDestinationTrack, nsTArray<RefPtr<MediaTrack>> aTracks,
|
|
|
|
++ AudioContextOperation aOperation,
|
|
|
|
++ MozPromiseHolder<AudioContextOperationPromise>&& aHolder)
|
|
|
|
++ : ControlMessage(aDestinationTrack),
|
|
|
|
++- mTracks(move(aTracks)),
|
|
|
|
+++ mTracks(std::move(aTracks)),
|
|
|
|
++ mAudioContextOperation(aOperation),
|
|
|
|
++- mHolder(move(aHolder)) {}
|
|
|
|
+++ mHolder(std::move(aHolder)) {}
|
|
|
|
++ void Run() override {
|
|
|
|
++ TRACE_COMMENT("MTG::ApplyAudioContextOperationImpl ControlMessage",
|
|
|
|
++ kAudioContextOptionsStrings[static_cast<uint8_t>(
|
|
|
|
++ mAudioContextOperation)]);
|
|
|
|
++ mTrack->GraphImpl()->ApplyAudioContextOperationImpl(this);
|
|
|
|
++ }
|
|
|
|
++ void RunDuringShutdown() override {
|
|
|
|
++ MOZ_ASSERT(mAudioContextOperation == AudioContextOperation::Close,
|
|
|
|
++@@ -3573,52 +3573,52 @@ void MediaTrackGraphImpl::ApplyAudioCont
|
|
|
|
++ auto moveDest = mPendingResumeOperations.begin();
|
|
|
|
++ for (PendingResumeOperation& op : mPendingResumeOperations) {
|
|
|
|
++ if (op.DestinationTrack() == destinationTrack) {
|
|
|
|
++ op.Apply(this);
|
|
|
|
++ shrinking = true;
|
|
|
|
++ continue;
|
|
|
|
++ }
|
|
|
|
++ if (shrinking) { // Fill-in gaps in the array.
|
|
|
|
++- *moveDest = move(op);
|
|
|
|
+++ *moveDest = std::move(op);
|
|
|
|
++ }
|
|
|
|
++ ++moveDest;
|
|
|
|
++ }
|
|
|
|
++ mPendingResumeOperations.TruncateLength(moveDest -
|
|
|
|
++ mPendingResumeOperations.begin());
|
|
|
|
++
|
|
|
|
++ for (MediaTrack* track : aMessage->mTracks) {
|
|
|
|
++ track->IncrementSuspendCount();
|
|
|
|
++ }
|
|
|
|
++ // Resolve after main thread state is up to date with completed processing.
|
|
|
|
++ DispatchToMainThreadStableState(NS_NewRunnableFunction(
|
|
|
|
++ "MediaTrackGraphImpl::ApplyAudioContextOperationImpl",
|
|
|
|
++- [holder = move(aMessage->mHolder), state]() mutable {
|
|
|
|
+++ [holder = std::move(aMessage->mHolder), state]() mutable {
|
|
|
|
++ holder.Resolve(state, __func__);
|
|
|
|
++ }));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ MediaTrackGraphImpl::PendingResumeOperation::PendingResumeOperation(
|
|
|
|
++ AudioContextOperationControlMessage* aMessage)
|
|
|
|
++ : mDestinationTrack(aMessage->GetTrack()),
|
|
|
|
++- mTracks(move(aMessage->mTracks)),
|
|
|
|
++- mHolder(move(aMessage->mHolder)) {
|
|
|
|
+++ mTracks(std::move(aMessage->mTracks)),
|
|
|
|
+++ mHolder(std::move(aMessage->mHolder)) {
|
|
|
|
++ MOZ_ASSERT(aMessage->mAudioContextOperation == AudioContextOperation::Resume);
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraphImpl::PendingResumeOperation::Apply(
|
|
|
|
++ MediaTrackGraphImpl* aGraph) {
|
|
|
|
++ MOZ_ASSERT(aGraph->OnGraphThread());
|
|
|
|
++ for (MediaTrack* track : mTracks) {
|
|
|
|
++ track->DecrementSuspendCount();
|
|
|
|
++ }
|
|
|
|
++ // The graph is provided through the parameter so that it is available even
|
|
|
|
++ // when the track is destroyed.
|
|
|
|
++ aGraph->DispatchToMainThreadStableState(NS_NewRunnableFunction(
|
|
|
|
++- "PendingResumeOperation::Apply", [holder = move(mHolder)]() mutable {
|
|
|
|
+++ "PendingResumeOperation::Apply", [holder = std::move(mHolder)]() mutable {
|
|
|
|
++ holder.Resolve(AudioContextState::Running, __func__);
|
|
|
|
++ }));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraphImpl::PendingResumeOperation::Abort() {
|
|
|
|
++ // The graph is shutting down before the operation completed.
|
|
|
|
++ #ifdef DEBUG
|
|
|
|
++ {
|
|
|
|
++@@ -3633,17 +3633,17 @@ void MediaTrackGraphImpl::PendingResumeO
|
|
|
|
++
|
|
|
|
++ auto MediaTrackGraph::ApplyAudioContextOperation(
|
|
|
|
++ MediaTrack* aDestinationTrack, nsTArray<RefPtr<MediaTrack>> aTracks,
|
|
|
|
++ AudioContextOperation aOperation) -> RefPtr<AudioContextOperationPromise> {
|
|
|
|
++ MozPromiseHolder<AudioContextOperationPromise> holder;
|
|
|
|
++ RefPtr<AudioContextOperationPromise> p = holder.Ensure(__func__);
|
|
|
|
++ MediaTrackGraphImpl* graphImpl = static_cast<MediaTrackGraphImpl*>(this);
|
|
|
|
++ graphImpl->AppendMessage(MakeUnique<AudioContextOperationControlMessage>(
|
|
|
|
++- aDestinationTrack, move(aTracks), aOperation, move(holder)));
|
|
|
|
+++ aDestinationTrack, std::move(aTracks), aOperation, std::move(holder)));
|
|
|
|
++ return p;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ uint32_t MediaTrackGraphImpl::AudioOutputChannelCount() const {
|
|
|
|
++ MOZ_ASSERT(OnGraphThread());
|
|
|
|
++ // The audio output channel count for a graph is the maximum of the output
|
|
|
|
++ // channel count of all the tracks that are in mAudioOutputs, or the max audio
|
|
|
|
++ // output channel count the machine can do, whichever is smaller.
|
|
|
|
++@@ -3829,17 +3829,17 @@ already_AddRefed<MediaInputPort> MediaTr
|
|
|
|
++ }
|
|
|
|
++ return nullptr;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void MediaTrackGraph::DispatchToMainThreadStableState(
|
|
|
|
++ already_AddRefed<nsIRunnable> aRunnable) {
|
|
|
|
++ AssertOnGraphThreadOrNotRunning();
|
|
|
|
++ static_cast<MediaTrackGraphImpl*>(this)
|
|
|
|
++- ->mPendingUpdateRunnables.AppendElement(move(aRunnable));
|
|
|
|
+++ ->mPendingUpdateRunnables.AppendElement(std::move(aRunnable));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ Watchable<mozilla::GraphTime>& MediaTrackGraphImpl::CurrentTime() {
|
|
|
|
++ MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
++ return mMainThreadGraphTime;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ GraphTime MediaTrackGraph::ProcessedTime() const {
|
|
|
|
+diff --git a/dom/media/fake-cdm/cdm-test-storage.cpp b/dom/media/fake-cdm/cdm-test-storage.cpp
|
|
|
|
+--- a/dom/media/fake-cdm/cdm-test-storage.cpp
|
|
|
|
++++ b/dom/media/fake-cdm/cdm-test-storage.cpp
|
|
|
|
+@@ -11,17 +11,17 @@
|
|
|
|
+
|
|
|
|
+ using namespace cdm;
|
|
|
|
+
|
|
|
|
+ class WriteRecordClient : public FileIOClient {
|
|
|
|
+ public:
|
|
|
|
+ WriteRecordClient(std::function<void()>&& aOnSuccess,
|
|
|
|
+ std::function<void()>&& aOnFailure, const uint8_t* aData,
|
|
|
|
+ uint32_t aDataSize)
|
|
|
|
+- : mOnSuccess(move(aOnSuccess)), mOnFailure(move(aOnFailure)) {
|
|
|
|
++ : mOnSuccess(std::move(aOnSuccess)), mOnFailure(std::move(aOnFailure)) {
|
|
|
|
+ mData.insert(mData.end(), aData, aData + aDataSize);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void OnOpenComplete(Status aStatus) override {
|
|
|
|
+ // If we hit an error, fail.
|
|
|
|
+ if (aStatus != Status::kSuccess) {
|
|
|
|
+ Done(aStatus);
|
|
|
|
+ } else if (mFileIO) { // Otherwise, write our data to the file.
|
|
|
|
+@@ -68,32 +68,33 @@ class WriteRecordClient : public FileIOC
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ void WriteRecord(Host_9* aHost, const std::string& aRecordName,
|
|
|
|
+ const uint8_t* aData, uint32_t aNumBytes,
|
|
|
|
+ std::function<void()>&& aOnSuccess,
|
|
|
|
+ std::function<void()>&& aOnFailure) {
|
|
|
|
+ // client will be delete in WriteRecordClient::Done
|
|
|
|
+ WriteRecordClient* client = new WriteRecordClient(
|
|
|
|
+- move(aOnSuccess), move(aOnFailure), aData, aNumBytes);
|
|
|
|
++ std::move(aOnSuccess), std::move(aOnFailure), aData, aNumBytes);
|
|
|
|
+ client->Do(aRecordName, aHost);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void WriteRecord(Host_9* aHost, const std::string& aRecordName,
|
|
|
|
+ const std::string& aData, std::function<void()>&& aOnSuccess,
|
|
|
|
+ std::function<void()>&& aOnFailure) {
|
|
|
|
+ return WriteRecord(aHost, aRecordName, (const uint8_t*)aData.c_str(),
|
|
|
|
+- aData.size(), move(aOnSuccess), move(aOnFailure));
|
|
|
|
++ aData.size(), std::move(aOnSuccess),
|
|
|
|
++ std::move(aOnFailure));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class ReadRecordClient : public FileIOClient {
|
|
|
|
+ public:
|
|
|
|
+ explicit ReadRecordClient(
|
|
|
|
+ std::function<void(bool, const uint8_t*, uint32_t)>&& aOnReadComplete)
|
|
|
|
+- : mOnReadComplete(move(aOnReadComplete)) {}
|
|
|
|
++ : mOnReadComplete(std::move(aOnReadComplete)) {}
|
|
|
|
+
|
|
|
|
+ void OnOpenComplete(Status aStatus) override {
|
|
|
|
+ auto err = aStatus;
|
|
|
|
+ if (aStatus != Status::kSuccess) {
|
|
|
|
+ Done(err, reinterpret_cast<const uint8_t*>(""), 0);
|
|
|
|
+ } else {
|
|
|
|
+ mFileIO->Read();
|
|
|
|
+ }
|
|
|
|
+@@ -136,24 +137,24 @@ class ReadRecordClient : public FileIOCl
|
|
|
|
+ FileIO* mFileIO = nullptr;
|
|
|
|
+ std::function<void(bool, const uint8_t*, uint32_t)> mOnReadComplete;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ void ReadRecord(
|
|
|
|
+ Host_9* aHost, const std::string& aRecordName,
|
|
|
|
+ std::function<void(bool, const uint8_t*, uint32_t)>&& aOnReadComplete) {
|
|
|
|
+ // client will be delete in ReadRecordClient::Done
|
|
|
|
+- ReadRecordClient* client = new ReadRecordClient(move(aOnReadComplete));
|
|
|
|
++ ReadRecordClient* client = new ReadRecordClient(std::move(aOnReadComplete));
|
|
|
|
+ client->Do(aRecordName, aHost);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class OpenRecordClient : public FileIOClient {
|
|
|
|
+ public:
|
|
|
|
+ explicit OpenRecordClient(std::function<void(bool)>&& aOpenComplete)
|
|
|
|
+- : mOpenComplete(move(aOpenComplete)) {}
|
|
|
|
++ : mOpenComplete(std::move(aOpenComplete)) {}
|
|
|
|
+
|
|
|
|
+ void OnOpenComplete(Status aStatus) override { Done(aStatus); }
|
|
|
|
+
|
|
|
|
+ void OnReadComplete(Status aStatus, const uint8_t* aData,
|
|
|
|
+ uint32_t aDataSize) override {}
|
|
|
|
+
|
|
|
|
+ void OnWriteComplete(Status aStatus) override {}
|
|
|
|
+
|
|
|
|
+@@ -187,11 +188,11 @@ class OpenRecordClient : public FileIOCl
|
|
|
|
+ FileIO* mFileIO = nullptr;
|
|
|
|
+ std::function<void(bool)> mOpenComplete;
|
|
|
|
+ ;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ void OpenRecord(Host_9* aHost, const std::string& aRecordName,
|
|
|
|
+ std::function<void(bool)>&& aOpenComplete) {
|
|
|
|
+ // client will be delete in OpenRecordClient::Done
|
|
|
|
+- OpenRecordClient* client = new OpenRecordClient(move(aOpenComplete));
|
|
|
|
++ OpenRecordClient* client = new OpenRecordClient(std::move(aOpenComplete));
|
|
|
|
+ client->Do(aRecordName, aHost);
|
|
|
|
+ }
|
|
|
|
+diff --git a/dom/media/webaudio/AudioContext.cpp.1757122.later b/dom/media/webaudio/AudioContext.cpp.1757122.later
|
|
|
|
+new file mode 100644
|
|
|
|
+--- /dev/null
|
|
|
|
++++ b/dom/media/webaudio/AudioContext.cpp.1757122.later
|
|
|
|
+@@ -0,0 +1,137 @@
|
|
|
|
++--- AudioContext.cpp
|
|
|
|
+++++ AudioContext.cpp
|
|
|
|
++@@ -84,18 +84,16 @@
|
|
|
|
++ #include "WaveShaperNode.h"
|
|
|
|
++ #include "Tracing.h"
|
|
|
|
++
|
|
|
|
++ extern mozilla::LazyLogModule gAutoplayPermissionLog;
|
|
|
|
++
|
|
|
|
++ #define AUTOPLAY_LOG(msg, ...) \
|
|
|
|
++ MOZ_LOG(gAutoplayPermissionLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
|
|
|
|
++
|
|
|
|
++-using std::move;
|
|
|
|
++-
|
|
|
|
++ namespace mozilla::dom {
|
|
|
|
++
|
|
|
|
++ // 0 is a special value that MediaTracks use to denote they are not part of a
|
|
|
|
++ // AudioContext.
|
|
|
|
++ static dom::AudioContext::AudioContextId gAudioContextId = 1;
|
|
|
|
++
|
|
|
|
++ NS_IMPL_CYCLE_COLLECTION_CLASS(AudioContext)
|
|
|
|
++
|
|
|
|
++@@ -676,17 +674,17 @@ already_AddRefed<Promise> AudioContext::
|
|
|
|
++ }
|
|
|
|
++ if (aSuccessCallback.WasPassed()) {
|
|
|
|
++ successCallback = &aSuccessCallback.Value();
|
|
|
|
++ }
|
|
|
|
++ UniquePtr<WebAudioDecodeJob> job(
|
|
|
|
++ new WebAudioDecodeJob(this, promise, successCallback, failureCallback));
|
|
|
|
++ AsyncDecodeWebAudio(contentType.get(), data, length, *job);
|
|
|
|
++ // Transfer the ownership to mDecodeJobs
|
|
|
|
++- mDecodeJobs.AppendElement(move(job));
|
|
|
|
+++ mDecodeJobs.AppendElement(std::move(job));
|
|
|
|
++
|
|
|
|
++ return promise.forget();
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void AudioContext::RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob) {
|
|
|
|
++ // Since UniquePtr doesn't provide an operator== which allows you to compare
|
|
|
|
++ // against raw pointers, we need to iterate manually.
|
|
|
|
++ for (uint32_t i = 0; i < mDecodeJobs.Length(); ++i) {
|
|
|
|
++@@ -847,17 +845,17 @@ class OnStateChangeTask final : public R
|
|
|
|
++
|
|
|
|
++ void AudioContext::Dispatch(already_AddRefed<nsIRunnable>&& aRunnable) {
|
|
|
|
++ MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
++ nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
|
|
|
|
++ // It can happen that this runnable took a long time to reach the main thread,
|
|
|
|
++ // and the global is not valid anymore.
|
|
|
|
++ if (parentObject) {
|
|
|
|
++ parentObject->AbstractMainThreadFor(TaskCategory::Other)
|
|
|
|
++- ->Dispatch(move(aRunnable));
|
|
|
|
+++ ->Dispatch(std::move(aRunnable));
|
|
|
|
++ } else {
|
|
|
|
++ RefPtr<nsIRunnable> runnable(aRunnable);
|
|
|
|
++ runnable = nullptr;
|
|
|
|
++ }
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState) {
|
|
|
|
++ MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
++@@ -1020,17 +1018,17 @@ void AudioContext::SuspendInternal(void*
|
|
|
|
++ // If mSuspendCalled is true then we already suspended all our tracks,
|
|
|
|
++ // so don't suspend them again (since suspend(); suspend(); resume(); should
|
|
|
|
++ // cancel both suspends). But we still need to do ApplyAudioContextOperation
|
|
|
|
++ // to ensure our new promise is resolved.
|
|
|
|
++ if (!mSuspendCalled) {
|
|
|
|
++ tracks = GetAllTracks();
|
|
|
|
++ }
|
|
|
|
++ auto promise = Graph()->ApplyAudioContextOperation(
|
|
|
|
++- DestinationTrack(), move(tracks), AudioContextOperation::Suspend);
|
|
|
|
+++ DestinationTrack(), std::move(tracks), AudioContextOperation::Suspend);
|
|
|
|
++ if ((aFlags & AudioContextOperationFlags::SendStateChange)) {
|
|
|
|
++ promise->Then(
|
|
|
|
++ GetMainThread(), "AudioContext::OnStateChanged",
|
|
|
|
++ [self = RefPtr<AudioContext>(this),
|
|
|
|
++ aPromise](AudioContextState aNewState) {
|
|
|
|
++ self->OnStateChanged(aPromise, aNewState);
|
|
|
|
++ },
|
|
|
|
++ [] { MOZ_CRASH("Unexpected rejection"); });
|
|
|
|
++@@ -1095,17 +1093,17 @@ void AudioContext::ResumeInternal(AudioC
|
|
|
|
++ // If mSuspendCalled is false then we already resumed all our tracks,
|
|
|
|
++ // so don't resume them again (since suspend(); resume(); resume(); should
|
|
|
|
++ // be OK). But we still need to do ApplyAudioContextOperation
|
|
|
|
++ // to ensure our new promise is resolved.
|
|
|
|
++ if (mSuspendCalled) {
|
|
|
|
++ tracks = GetAllTracks();
|
|
|
|
++ }
|
|
|
|
++ auto promise = Graph()->ApplyAudioContextOperation(
|
|
|
|
++- DestinationTrack(), move(tracks), AudioContextOperation::Resume);
|
|
|
|
+++ DestinationTrack(), std::move(tracks), AudioContextOperation::Resume);
|
|
|
|
++ if (aFlags & AudioContextOperationFlags::SendStateChange) {
|
|
|
|
++ promise->Then(
|
|
|
|
++ GetMainThread(), "AudioContext::OnStateChanged",
|
|
|
|
++ [self = RefPtr<AudioContext>(this)](AudioContextState aNewState) {
|
|
|
|
++ self->OnStateChanged(nullptr, aNewState);
|
|
|
|
++ },
|
|
|
|
++ [] {}); // Promise may be rejected after graph shutdown.
|
|
|
|
++ }
|
|
|
|
++@@ -1227,17 +1225,17 @@ void AudioContext::CloseInternal(void* a
|
|
|
|
++ nsTArray<RefPtr<mozilla::MediaTrack>> tracks;
|
|
|
|
++ // If mSuspendCalled or mCloseCalled are true then we already suspended
|
|
|
|
++ // all our tracks, so don't suspend them again. But we still need to do
|
|
|
|
++ // ApplyAudioContextOperation to ensure our new promise is resolved.
|
|
|
|
++ if (!mSuspendCalled && !mCloseCalled) {
|
|
|
|
++ tracks = GetAllTracks();
|
|
|
|
++ }
|
|
|
|
++ auto promise = Graph()->ApplyAudioContextOperation(
|
|
|
|
++- ds, move(tracks), AudioContextOperation::Close);
|
|
|
|
+++ ds, std::move(tracks), AudioContextOperation::Close);
|
|
|
|
++ if ((aFlags & AudioContextOperationFlags::SendStateChange)) {
|
|
|
|
++ promise->Then(
|
|
|
|
++ GetMainThread(), "AudioContext::OnStateChanged",
|
|
|
|
++ [self = RefPtr<AudioContext>(this),
|
|
|
|
++ aPromise](AudioContextState aNewState) {
|
|
|
|
++ self->OnStateChanged(aPromise, aNewState);
|
|
|
|
++ },
|
|
|
|
++ [] {}); // Promise may be rejected after graph shutdown.
|
|
|
|
++@@ -1296,18 +1294,18 @@ void AudioContext::Unmute() const {
|
|
|
|
++ if (mDestination) {
|
|
|
|
++ mDestination->Unmute();
|
|
|
|
++ }
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ void AudioContext::SetParamMapForWorkletName(
|
|
|
|
++ const nsAString& aName, AudioParamDescriptorMap* aParamMap) {
|
|
|
|
++ MOZ_ASSERT(!mWorkletParamDescriptors.Contains(aName));
|
|
|
|
++- Unused << mWorkletParamDescriptors.InsertOrUpdate(aName, move(*aParamMap),
|
|
|
|
++- fallible);
|
|
|
|
+++ Unused << mWorkletParamDescriptors.InsertOrUpdate(
|
|
|
|
+++ aName, std::move(*aParamMap), fallible);
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ size_t AudioContext::SizeOfIncludingThis(
|
|
|
|
++ mozilla::MallocSizeOf aMallocSizeOf) const {
|
|
|
|
++ // AudioNodes are tracked separately because we do not want the AudioContext
|
|
|
|
++ // to track all of the AudioNodes it creates, so we wouldn't be able to
|
|
|
|
++ // traverse them from here.
|
|
|
|
++
|
|
|
|
+diff --git a/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp b/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp
|
|
|
|
+--- a/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp
|
|
|
|
++++ b/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp
|
|
|
|
+@@ -59,17 +59,17 @@ ClearKeyPersistence::ReadAllRecordsFromI
|
|
|
|
+ [self, aOnComplete] ()
|
|
|
|
+ {
|
|
|
|
+ CK_LOGD("ClearKeyPersistence: Failed to load index file (it might not exist");
|
|
|
|
+ self->mPersistentKeyState = PersistentKeyState::LOADED;
|
|
|
|
+ aOnComplete();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ string filename = "index";
|
|
|
|
+- ReadData(mHost, filename, move(onIndexSuccess), move(onIndexFailed));
|
|
|
|
++ ReadData(mHost, filename, std::move(onIndexSuccess), std::move(onIndexFailed));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeyPersistence::WriteIndex() {
|
|
|
|
+ function <void()> onIndexSuccess =
|
|
|
|
+ [] ()
|
|
|
|
+ {
|
|
|
|
+ CK_LOGD("ClearKeyPersistence: Wrote index file");
|
|
|
|
+@@ -91,34 +91,34 @@ ClearKeyPersistence::WriteIndex() {
|
|
|
|
+ string dataString = ss.str();
|
|
|
|
+ uint8_t* dataArray = (uint8_t*)dataString.data();
|
|
|
|
+ vector<uint8_t> data(dataArray, dataArray + dataString.size());
|
|
|
|
+
|
|
|
|
+ string filename = "index";
|
|
|
|
+ WriteData(mHost,
|
|
|
|
+ filename,
|
|
|
|
+ data,
|
|
|
|
+- move(onIndexSuccess),
|
|
|
|
+- move(onIndexFail));
|
|
|
|
++ std::move(onIndexSuccess),
|
|
|
|
++ std::move(onIndexFail));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ClearKeyPersistence::ClearKeyPersistence(Host_9* aHost)
|
|
|
|
+ {
|
|
|
|
+ this->mHost = aHost;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeyPersistence::EnsureInitialized(bool aPersistentStateAllowed,
|
|
|
|
+ function<void()>&& aOnInitialized)
|
|
|
|
+ {
|
|
|
|
+ if (aPersistentStateAllowed &&
|
|
|
|
+ mPersistentKeyState == PersistentKeyState::UNINITIALIZED) {
|
|
|
|
+ mPersistentKeyState = LOADING;
|
|
|
|
+- ReadAllRecordsFromIndex(move(aOnInitialized));
|
|
|
|
++ ReadAllRecordsFromIndex(std::move(aOnInitialized));
|
|
|
|
+ } else {
|
|
|
|
+ mPersistentKeyState = PersistentKeyState::LOADED;
|
|
|
|
+ aOnInitialized();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool ClearKeyPersistence::IsLoaded() const
|
|
|
|
+ {
|
|
|
|
+diff --git a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
|
|
|
|
+--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
|
|
|
|
++++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
|
|
|
|
+@@ -62,17 +62,17 @@ ClearKeySessionManager::Init(bool aDisti
|
|
|
|
+ function<void()> func = self->mDeferredInitialize.front();
|
|
|
|
+ self->mDeferredInitialize.pop();
|
|
|
|
+
|
|
|
|
+ func();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ mPersistence->EnsureInitialized(aPersistentStateAllowed,
|
|
|
|
+- move(onPersistentStateLoaded));
|
|
|
|
++ std::move(onPersistentStateLoaded));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeySessionManager::CreateSession(uint32_t aPromiseId,
|
|
|
|
+ InitDataType aInitDataType,
|
|
|
|
+ const uint8_t* aInitData,
|
|
|
|
+ uint32_t aInitDataSize,
|
|
|
|
+ SessionType aSessionType)
|
|
|
|
+@@ -89,17 +89,17 @@ ClearKeySessionManager::CreateSession(ui
|
|
|
|
+ self->CreateSession(aPromiseId,
|
|
|
|
+ aInitDataType,
|
|
|
|
+ initData.data(),
|
|
|
|
+ initData.size(),
|
|
|
|
+ aSessionType);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // If we haven't loaded, don't do this yet
|
|
|
|
+- if (MaybeDeferTillInitialized(move(deferrer))) {
|
|
|
|
++ if (MaybeDeferTillInitialized(std::move(deferrer))) {
|
|
|
|
+ CK_LOGD("Deferring CreateSession");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CK_LOGARRAY("ClearKeySessionManager::CreateSession initdata: ",
|
|
|
|
+ aInitData,
|
|
|
|
+ aInitDataSize);
|
|
|
|
+
|
|
|
|
+@@ -195,17 +195,17 @@ ClearKeySessionManager::LoadSession(uint
|
|
|
|
+ // we try to use it.
|
|
|
|
+ RefPtr<ClearKeySessionManager> self(this);
|
|
|
|
+ function<void()> deferrer =
|
|
|
|
+ [self, aPromiseId, sessionId] ()
|
|
|
|
+ {
|
|
|
|
+ self->LoadSession(aPromiseId, sessionId.data(), sessionId.size());
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+- if (MaybeDeferTillInitialized(move(deferrer))) {
|
|
|
|
++ if (MaybeDeferTillInitialized(std::move(deferrer))) {
|
|
|
|
+ CK_LOGD("Deferring LoadSession");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If the SessionManager has been shutdown mHost will be null and we won't
|
|
|
|
+ // be able to resolve the promise.
|
|
|
|
+ if (!mHost) {
|
|
|
|
+ return;
|
|
|
|
+@@ -233,17 +233,17 @@ ClearKeySessionManager::LoadSession(uint
|
|
|
|
+ function<void()> failure = [self, aPromiseId] {
|
|
|
|
+ if (!self->mHost) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // As per the API described in ContentDecryptionModule_8
|
|
|
|
+ self->mHost->OnResolveNewSessionPromise(aPromiseId, nullptr, 0);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+- ReadData(mHost, sessionId, move(success), move(failure));
|
|
|
|
++ ReadData(mHost, sessionId, std::move(success), std::move(failure));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeySessionManager::PersistentSessionDataLoaded(uint32_t aPromiseId,
|
|
|
|
+ const string& aSessionId,
|
|
|
|
+ const uint8_t* aKeyData,
|
|
|
|
+ uint32_t aKeyDataSize)
|
|
|
|
+ {
|
|
|
|
+@@ -331,17 +331,17 @@ ClearKeySessionManager::UpdateSession(ui
|
|
|
|
+ self->UpdateSession(aPromiseId,
|
|
|
|
+ sessionId.data(),
|
|
|
|
+ sessionId.size(),
|
|
|
|
+ response.data(),
|
|
|
|
+ response.size());
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // If we haven't fully loaded, defer calling this method
|
|
|
|
+- if (MaybeDeferTillInitialized(move(deferrer))) {
|
|
|
|
++ if (MaybeDeferTillInitialized(std::move(deferrer))) {
|
|
|
|
+ CK_LOGD("Deferring LoadSession");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Make sure the SessionManager has not been shutdown before we try and
|
|
|
|
+ // resolve any promises.
|
|
|
|
+ if (!mHost) {
|
|
|
|
+ return;
|
|
|
|
+@@ -441,17 +441,17 @@ ClearKeySessionManager::UpdateSession(ui
|
|
|
|
+ static const char* message = "Couldn't store cenc key init data";
|
|
|
|
+ self->mHost->OnRejectPromise(aPromiseId,
|
|
|
|
+ Exception::kExceptionInvalidStateError,
|
|
|
|
+ 0,
|
|
|
|
+ message,
|
|
|
|
+ strlen(message));
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+- WriteData(mHost, sessionId, keydata, move(resolve), move(reject));
|
|
|
|
++ WriteData(mHost, sessionId, keydata, std::move(resolve), std::move(reject));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeySessionManager::Serialize(const ClearKeySession* aSession,
|
|
|
|
+ std::vector<uint8_t>& aOutKeyData)
|
|
|
|
+ {
|
|
|
|
+ const std::vector<KeyId>& keyIds = aSession->GetKeyIds();
|
|
|
|
+ for (size_t i = 0; i < keyIds.size(); i++) {
|
|
|
|
+@@ -481,17 +481,17 @@ ClearKeySessionManager::CloseSession(uin
|
|
|
|
+ RefPtr<ClearKeySessionManager> self(this);
|
|
|
|
+ function<void()> deferrer =
|
|
|
|
+ [self, aPromiseId, sessionId] ()
|
|
|
|
+ {
|
|
|
|
+ self->CloseSession(aPromiseId, sessionId.data(), sessionId.size());
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // If we haven't loaded, call this method later.
|
|
|
|
+- if (MaybeDeferTillInitialized(move(deferrer))) {
|
|
|
|
++ if (MaybeDeferTillInitialized(std::move(deferrer))) {
|
|
|
|
+ CK_LOGD("Deferring CloseSession");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If DecryptingComplete has been called mHost will be null and we won't
|
|
|
|
+ // be able to resolve our promise.
|
|
|
|
+ if (!mHost) {
|
|
|
|
+ return;
|
|
|
|
+@@ -540,17 +540,17 @@ ClearKeySessionManager::RemoveSession(ui
|
|
|
|
+ RefPtr<ClearKeySessionManager> self(this);
|
|
|
|
+ function<void()> deferrer =
|
|
|
|
+ [self, aPromiseId, sessionId] ()
|
|
|
|
+ {
|
|
|
|
+ self->RemoveSession(aPromiseId, sessionId.data(), sessionId.size());
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // If we haven't fully loaded, defer calling this method.
|
|
|
|
+- if (MaybeDeferTillInitialized(move(deferrer))) {
|
|
|
|
++ if (MaybeDeferTillInitialized(std::move(deferrer))) {
|
|
|
|
+ CK_LOGD("Deferring RemoveSession");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Check that the SessionManager has not been shutdown before we try and
|
|
|
|
+ // resolve any promises.
|
|
|
|
+ if (!mHost) {
|
|
|
|
+ return;
|
|
|
|
+@@ -600,17 +600,17 @@ ClearKeySessionManager::RemoveSession(ui
|
|
|
|
+ static const char* message = "Could not remove session";
|
|
|
|
+ self->mHost->OnRejectPromise(aPromiseId,
|
|
|
|
+ Exception::kExceptionTypeError,
|
|
|
|
+ 0,
|
|
|
|
+ message,
|
|
|
|
+ strlen(message));
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+- WriteData(mHost, sessionId, emptyKeydata, move(resolve), move(reject));
|
|
|
|
++ WriteData(mHost, sessionId, emptyKeydata, std::move(resolve), std::move(reject));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void
|
|
|
|
+ ClearKeySessionManager::SetServerCertificate(uint32_t aPromiseId,
|
|
|
|
+ const uint8_t* aServerCert,
|
|
|
|
+ uint32_t aServerCertSize)
|
|
|
|
+ {
|
|
|
|
+ // ClearKey CDM doesn't support this method by spec.
|
|
|
|
+@@ -669,11 +669,11 @@ ClearKeySessionManager::DecryptingComple
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool ClearKeySessionManager::MaybeDeferTillInitialized(function<void()>&& aMaybeDefer)
|
|
|
|
+ {
|
|
|
|
+ if (mPersistence->IsLoaded()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+- mDeferredInitialize.emplace(move(aMaybeDefer));
|
|
|
|
++ mDeferredInitialize.emplace(std::move(aMaybeDefer));
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+diff --git a/media/gmp-clearkey/0.1/ClearKeyStorage.cpp b/media/gmp-clearkey/0.1/ClearKeyStorage.cpp
|
|
|
|
+--- a/media/gmp-clearkey/0.1/ClearKeyStorage.cpp
|
|
|
|
++++ b/media/gmp-clearkey/0.1/ClearKeyStorage.cpp
|
|
|
|
+@@ -39,18 +39,18 @@ public:
|
|
|
|
+ */
|
|
|
|
+ static void Write(Host_9* aHost,
|
|
|
|
+ string& aRecordName,
|
|
|
|
+ const vector<uint8_t>& aData,
|
|
|
|
+ function<void()>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ {
|
|
|
|
+ WriteRecordClient* client = new WriteRecordClient(aData,
|
|
|
|
+- move(aOnSuccess),
|
|
|
|
+- move(aOnFailure));
|
|
|
|
++ std::move(aOnSuccess),
|
|
|
|
++ std::move(aOnFailure));
|
|
|
|
+ client->Do(aRecordName, aHost);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void OnOpenComplete(Status aStatus) override
|
|
|
|
+ {
|
|
|
|
+ // If we hit an error, fail.
|
|
|
|
+ if (aStatus != Status::kSuccess) {
|
|
|
|
+ Done(aStatus);
|
|
|
|
+@@ -73,18 +73,18 @@ public:
|
|
|
|
+ Done(aStatus);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ explicit WriteRecordClient(const vector<uint8_t>& aData,
|
|
|
|
+ function<void()>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ : mFileIO(nullptr)
|
|
|
|
+- , mOnSuccess(move(aOnSuccess))
|
|
|
|
+- , mOnFailure(move(aOnFailure))
|
|
|
|
++ , mOnSuccess(std::move(aOnSuccess))
|
|
|
|
++ , mOnFailure(std::move(aOnFailure))
|
|
|
|
+ , mData(aData) {}
|
|
|
|
+
|
|
|
|
+ void Do(const string& aName, Host_9* aHost)
|
|
|
|
+ {
|
|
|
|
+ // Initialize the FileIO.
|
|
|
|
+ mFileIO = aHost->CreateFileIO(this);
|
|
|
|
+ mFileIO->Open(aName.c_str(), aName.size());
|
|
|
|
+ }
|
|
|
|
+@@ -122,34 +122,34 @@ WriteData(Host_9* aHost,
|
|
|
|
+ string& aRecordName,
|
|
|
|
+ const vector<uint8_t>& aData,
|
|
|
|
+ function<void()>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ {
|
|
|
|
+ WriteRecordClient::Write(aHost,
|
|
|
|
+ aRecordName,
|
|
|
|
+ aData,
|
|
|
|
+- move(aOnSuccess),
|
|
|
|
+- move(aOnFailure));
|
|
|
|
++ std::move(aOnSuccess),
|
|
|
|
++ std::move(aOnFailure));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class ReadRecordClient : public FileIOClient
|
|
|
|
+ {
|
|
|
|
+ public:
|
|
|
|
+ /*
|
|
|
|
+ * This function will take the memory ownership of the parameters and
|
|
|
|
+ * delete them when done.
|
|
|
|
+ */
|
|
|
|
+ static void Read(Host_9* aHost,
|
|
|
|
+ string& aRecordName,
|
|
|
|
+ function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+- (new ReadRecordClient(move(aOnSuccess), move(aOnFailure)))->
|
|
|
|
++ (new ReadRecordClient(std::move(aOnSuccess), std::move(aOnFailure)))->
|
|
|
|
+ Do(aRecordName, aHost);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void OnOpenComplete(Status aStatus) override
|
|
|
|
+ {
|
|
|
|
+ auto err = aStatus;
|
|
|
|
+ if (aStatus != Status::kSuccess) {
|
|
|
|
+ Done(err, nullptr, 0);
|
|
|
|
+@@ -170,18 +170,18 @@ public:
|
|
|
|
+ // We should never reach here, this client only ever reads data.
|
|
|
|
+ assert(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ explicit ReadRecordClient(function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ : mFileIO(nullptr)
|
|
|
|
+- , mOnSuccess(move(aOnSuccess))
|
|
|
|
+- , mOnFailure(move(aOnFailure))
|
|
|
|
++ , mOnSuccess(std::move(aOnSuccess))
|
|
|
|
++ , mOnFailure(std::move(aOnFailure))
|
|
|
|
+ {}
|
|
|
|
+
|
|
|
|
+ void Do(const string& aName, Host_9* aHost)
|
|
|
|
+ {
|
|
|
|
+ mFileIO = aHost->CreateFileIO(this);
|
|
|
|
+ mFileIO->Open(aName.c_str(), aName.size());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+@@ -216,11 +216,11 @@ private:
|
|
|
|
+ void
|
|
|
|
+ ReadData(Host_9* mHost,
|
|
|
|
+ string& aRecordName,
|
|
|
|
+ function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
|
|
|
|
+ function<void()>&& aOnFailure)
|
|
|
|
+ {
|
|
|
|
+ ReadRecordClient::Read(mHost,
|
|
|
|
+ aRecordName,
|
|
|
|
+- move(aOnSuccess),
|
|
|
|
+- move(aOnFailure));
|
|
|
|
++ std::move(aOnSuccess),
|
|
|
|
++ std::move(aOnFailure));
|
|
|
|
+ }
|
|
|
|
+diff --git a/xpcom/tests/gtest/TestThrottledEventQueue.cpp.1757122.later b/xpcom/tests/gtest/TestThrottledEventQueue.cpp.1757122.later
|
|
|
|
+new file mode 100644
|
|
|
|
+--- /dev/null
|
|
|
|
++++ b/xpcom/tests/gtest/TestThrottledEventQueue.cpp.1757122.later
|
|
|
|
+@@ -0,0 +1,60 @@
|
|
|
|
++--- TestThrottledEventQueue.cpp
|
|
|
|
+++++ TestThrottledEventQueue.cpp
|
|
|
|
++@@ -25,17 +25,16 @@
|
|
|
|
++ #include "prinrval.h"
|
|
|
|
++
|
|
|
|
++ using mozilla::CondVar;
|
|
|
|
++ using mozilla::MakeRefPtr;
|
|
|
|
++ using mozilla::Mutex;
|
|
|
|
++ using mozilla::MutexAutoLock;
|
|
|
|
++ using mozilla::ThrottledEventQueue;
|
|
|
|
++ using std::function;
|
|
|
|
++-using std::move;
|
|
|
|
++ using std::string;
|
|
|
|
++
|
|
|
|
++ namespace TestThrottledEventQueue {
|
|
|
|
++
|
|
|
|
++ // A simple queue of runnables, to serve as the base target of
|
|
|
|
++ // ThrottledEventQueues in tests.
|
|
|
|
++ //
|
|
|
|
++ // This is much simpler than mozilla::TaskQueue, and so better for unit tests.
|
|
|
|
++@@ -44,17 +43,17 @@ namespace TestThrottledEventQueue {
|
|
|
|
++ struct RunnableQueue : nsISerialEventTarget {
|
|
|
|
++ std::queue<nsCOMPtr<nsIRunnable>> runnables;
|
|
|
|
++
|
|
|
|
++ bool IsEmpty() { return runnables.empty(); }
|
|
|
|
++ size_t Length() { return runnables.size(); }
|
|
|
|
++
|
|
|
|
++ [[nodiscard]] nsresult Run() {
|
|
|
|
++ while (!runnables.empty()) {
|
|
|
|
++- auto runnable = move(runnables.front());
|
|
|
|
+++ auto runnable = std::move(runnables.front());
|
|
|
|
++ runnables.pop();
|
|
|
|
++ nsresult rv = runnable->Run();
|
|
|
|
++ if (NS_FAILED(rv)) return rv;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ return NS_OK;
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++@@ -92,18 +91,18 @@ struct RunnableQueue : nsISerialEventTar
|
|
|
|
++
|
|
|
|
++ private:
|
|
|
|
++ virtual ~RunnableQueue() = default;
|
|
|
|
++ };
|
|
|
|
++
|
|
|
|
++ NS_IMPL_ISUPPORTS(RunnableQueue, nsIEventTarget, nsISerialEventTarget)
|
|
|
|
++
|
|
|
|
++ static void Enqueue(nsIEventTarget* target, function<void()>&& aCallable) {
|
|
|
|
++- nsresult rv =
|
|
|
|
++- target->Dispatch(NS_NewRunnableFunction("TEQ GTest", move(aCallable)));
|
|
|
|
+++ nsresult rv = target->Dispatch(
|
|
|
|
+++ NS_NewRunnableFunction("TEQ GTest", std::move(aCallable)));
|
|
|
|
++ MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
|
|
|
|
++ }
|
|
|
|
++
|
|
|
|
++ } // namespace TestThrottledEventQueue
|
|
|
|
++
|
|
|
|
++ using namespace TestThrottledEventQueue;
|
|
|
|
++
|
|
|
|
++ TEST(ThrottledEventQueue, RunnableQueue)
|