mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import change from rmottola/Arctic-Fox:
- Bug 1094764 - Implement AudioContext.suspend and friends. r=roc,ehsan (79ff7e5ea) (and GraphDriver.cpp vc2013 fix from bug1163469) - Bug 1147699 - Part 2: Set the content policy type on FetchEvent.request based on the content policy type of the channel; r=nsm (f4bfbb8e2) - Bug 1147699 - Part 3: Add a test for FetchEvent.request.context when intercepting an image load; (36e429469) - Bug 1147699 - Part 4: Add a test for FetchEvent.request.context when intercepting a responsive image load; (c7f4a27f3) - Bug 1147699 - Part 5: Add a test for FetchEvent.request.context when intercepting an audio element load; (40dfbeb87) - Bug 1147699 - Part 6: Add a test for FetchEvent.request.context when intercepting a video element load; (dcc6a359a) - Bug 1147699 - Part 7: Add a test for FetchEvent.request.context when intercepting a beacon load; (8cb913bff) - Bug 1147699 - Part 8: Add a test for FetchEvent.request.context when intercepting a CSP report (67d7ab74a) - Bug 1147699 - Part 9: Add tests for FetchEvent.request.context when intercepting embeds and objects; (b7f8d3c11) - Bug 1147699 - Part 10: Add a test for FetchEvent.request.context when intercepting font loads; (4108db24e) - Bug 1147699 - Part 11: Add tests for FetchEvent.request.context when intercepting iframes and frames; (981c93483) - Bug 1147699 - Part 12: Add a test for FetchEvent.request.context when intercepting new window loads; (cd1ce857f) - Bug 1147699 - Part 13: Add a test for FetchEvent.request.context when intercepting ping loads; r=nsm (377e09600) - Bug 1146610 - Add static_asserts that check the validity of the enum values that we write into the cache database; r=bkelly (ac8c96abc) - Bug 1147699 - Part 14: Add a test for FetchEvent.request.context when intercepting loads coming from plugins; r=nsm (0e1769bb4) - Bug 1148064 - Enable interception of pings through service workers; r=nsm,smaug (8dc3328cb) - Bug 1150608 Do not reuse CacheId values within an origin. (4eb46f1d5)
This commit is contained in:
+74
-46
@@ -23,7 +23,7 @@ extern PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
#ifdef ENABLE_LIFECYCLE_LOG
|
||||
#ifdef ANDROID
|
||||
#include "android/log.h"
|
||||
#define LIFECYCLE_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Goanna - MSG" , ## __VA_ARGS__); printf(__VA_ARGS__);printf("\n");
|
||||
#define LIFECYCLE_LOG(...) __android_log_print(ANDROID_LOG_INFO, "Goanna - MSG" , __VA_ARGS__); printf(__VA_ARGS__);printf("\n");
|
||||
#else
|
||||
#define LIFECYCLE_LOG(...) printf(__VA_ARGS__);printf("\n");
|
||||
#endif
|
||||
@@ -95,9 +95,6 @@ void GraphDriver::SwitchAtNextIteration(GraphDriver* aNextDriver)
|
||||
LIFECYCLE_LOG("Switching to new driver: %p (%s)",
|
||||
aNextDriver, aNextDriver->AsAudioCallbackDriver() ?
|
||||
"AudioCallbackDriver" : "SystemClockDriver");
|
||||
// Sometimes we switch twice to a new driver per iteration, this is probably a
|
||||
// bug.
|
||||
MOZ_ASSERT(!mNextDriver || mNextDriver->AsAudioCallbackDriver());
|
||||
mNextDriver = aNextDriver;
|
||||
}
|
||||
|
||||
@@ -145,7 +142,7 @@ public:
|
||||
LIFECYCLE_LOG("Releasing audio driver off main thread.");
|
||||
nsRefPtr<AsyncCubebTask> releaseEvent =
|
||||
new AsyncCubebTask(mDriver->AsAudioCallbackDriver(),
|
||||
AsyncCubebTask::SHUTDOWN);
|
||||
AsyncCubebOperation::SHUTDOWN);
|
||||
mDriver = nullptr;
|
||||
releaseEvent->Dispatch();
|
||||
} else {
|
||||
@@ -163,7 +160,7 @@ void GraphDriver::Shutdown()
|
||||
if (AsAudioCallbackDriver()) {
|
||||
LIFECYCLE_LOG("Releasing audio driver off main thread (GraphDriver::Shutdown).\n");
|
||||
nsRefPtr<AsyncCubebTask> releaseEvent =
|
||||
new AsyncCubebTask(AsAudioCallbackDriver(), AsyncCubebTask::SHUTDOWN);
|
||||
new AsyncCubebTask(AsAudioCallbackDriver(), AsyncCubebOperation::SHUTDOWN);
|
||||
releaseEvent->Dispatch();
|
||||
} else {
|
||||
Stop();
|
||||
@@ -204,7 +201,7 @@ public:
|
||||
// because the osx audio stack is currently switching output device.
|
||||
if (!mDriver->mPreviousDriver->AsAudioCallbackDriver()->IsSwitchingDevice()) {
|
||||
nsRefPtr<AsyncCubebTask> releaseEvent =
|
||||
new AsyncCubebTask(mDriver->mPreviousDriver->AsAudioCallbackDriver(), AsyncCubebTask::SHUTDOWN);
|
||||
new AsyncCubebTask(mDriver->mPreviousDriver->AsAudioCallbackDriver(), AsyncCubebOperation::SHUTDOWN);
|
||||
mDriver->mPreviousDriver = nullptr;
|
||||
releaseEvent->Dispatch();
|
||||
}
|
||||
@@ -505,36 +502,21 @@ AsyncCubebTask::Run()
|
||||
MOZ_ASSERT(mDriver);
|
||||
|
||||
switch(mOperation) {
|
||||
case AsyncCubebOperation::INIT:
|
||||
case AsyncCubebOperation::INIT: {
|
||||
LIFECYCLE_LOG("AsyncCubebOperation::INIT\n");
|
||||
mDriver->Init();
|
||||
mDriver->CompleteAudioContextOperations(mOperation);
|
||||
break;
|
||||
case AsyncCubebOperation::SHUTDOWN:
|
||||
}
|
||||
case AsyncCubebOperation::SHUTDOWN: {
|
||||
LIFECYCLE_LOG("AsyncCubebOperation::SHUTDOWN\n");
|
||||
mDriver->Stop();
|
||||
|
||||
mDriver->CompleteAudioContextOperations(mOperation);
|
||||
|
||||
mDriver = nullptr;
|
||||
mShutdownGrip = nullptr;
|
||||
break;
|
||||
case AsyncCubebOperation::SLEEP: {
|
||||
{
|
||||
LIFECYCLE_LOG("AsyncCubebOperation::SLEEP\n");
|
||||
MonitorAutoLock mon(mDriver->mGraphImpl->GetMonitor());
|
||||
// We might just have been awoken
|
||||
if (mDriver->mGraphImpl->mNeedAnotherIteration) {
|
||||
mDriver->mPauseRequested = false;
|
||||
mDriver->mWaitState = AudioCallbackDriver::WAITSTATE_RUNNING;
|
||||
mDriver->mGraphImpl->mGraphDriverAsleep = false ; // atomic
|
||||
break;
|
||||
}
|
||||
mDriver->Stop();
|
||||
mDriver->mGraphImpl->mGraphDriverAsleep = true; // atomic
|
||||
mDriver->mWaitState = AudioCallbackDriver::WAITSTATE_WAITING_INDEFINITELY;
|
||||
mDriver->mPauseRequested = false;
|
||||
mDriver->mGraphImpl->GetMonitor().Wait(PR_INTERVAL_NO_TIMEOUT);
|
||||
}
|
||||
STREAM_LOG(PR_LOG_DEBUG, ("Restarting audio stream from sleep."));
|
||||
mDriver->StartStream();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("Operation not implemented.");
|
||||
@@ -546,6 +528,16 @@ AsyncCubebTask::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
StreamAndPromiseForOperation::StreamAndPromiseForOperation(MediaStream* aStream,
|
||||
void* aPromise,
|
||||
dom::AudioContextOperation aOperation)
|
||||
: mStream(aStream)
|
||||
, mPromise(aPromise)
|
||||
, mOperation(aOperation)
|
||||
{
|
||||
MOZ_ASSERT(aPromise);
|
||||
}
|
||||
|
||||
AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl, dom::AudioChannel aChannel)
|
||||
: GraphDriver(aGraphImpl)
|
||||
, mIterationDurationMS(MEDIA_GRAPH_TARGET_PERIOD_MS)
|
||||
@@ -561,7 +553,9 @@ AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl, dom::
|
||||
}
|
||||
|
||||
AudioCallbackDriver::~AudioCallbackDriver()
|
||||
{}
|
||||
{
|
||||
MOZ_ASSERT(mPromisesForOperation.IsEmpty());
|
||||
}
|
||||
|
||||
void
|
||||
AudioCallbackDriver::Init()
|
||||
@@ -651,12 +645,18 @@ AudioCallbackDriver::Start()
|
||||
if (NS_IsMainThread()) {
|
||||
STREAM_LOG(PR_LOG_DEBUG, ("Starting audio threads for MediaStreamGraph %p from a new thread.", mGraphImpl));
|
||||
nsRefPtr<AsyncCubebTask> initEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebTask::INIT);
|
||||
new AsyncCubebTask(this, AsyncCubebOperation::INIT);
|
||||
initEvent->Dispatch();
|
||||
} else {
|
||||
STREAM_LOG(PR_LOG_DEBUG, ("Starting audio threads for MediaStreamGraph %p from the previous driver's thread", mGraphImpl));
|
||||
Init();
|
||||
|
||||
// Check if we need to resolve promises because the driver just got switched
|
||||
// because of a resuming AudioContext
|
||||
if (!mPromisesForOperation.IsEmpty()) {
|
||||
CompleteAudioContextOperations(AsyncCubebOperation::INIT);
|
||||
}
|
||||
|
||||
if (mPreviousDriver) {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new MediaStreamGraphShutdownThreadRunnable(mPreviousDriver);
|
||||
@@ -704,7 +704,7 @@ AudioCallbackDriver::Revive()
|
||||
} else {
|
||||
STREAM_LOG(PR_LOG_DEBUG, ("Starting audio threads for MediaStreamGraph %p from a new thread.", mGraphImpl));
|
||||
nsRefPtr<AsyncCubebTask> initEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebTask::INIT);
|
||||
new AsyncCubebTask(this, AsyncCubebOperation::INIT);
|
||||
initEvent->Dispatch();
|
||||
}
|
||||
}
|
||||
@@ -729,20 +729,6 @@ AudioCallbackDriver::GetCurrentTime()
|
||||
|
||||
void AudioCallbackDriver::WaitForNextIteration()
|
||||
{
|
||||
#if 0
|
||||
mGraphImpl->GetMonitor().AssertCurrentThreadOwns();
|
||||
|
||||
// We can't block on the monitor in the audio callback, so we kick off a new
|
||||
// thread that will pause the audio stream, and restart it when unblocked.
|
||||
// We don't want to sleep when we haven't started the driver yet.
|
||||
if (!mGraphImpl->mNeedAnotherIteration && mAudioStream && mGraphImpl->Running()) {
|
||||
STREAM_LOG(PR_LOG_DEBUG+1, ("AudioCallbackDriver going to sleep"));
|
||||
mPauseRequested = true;
|
||||
nsRefPtr<AsyncCubebTask> sleepEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebTask::SLEEP);
|
||||
sleepEvent->Dispatch();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1074,5 +1060,47 @@ AudioCallbackDriver::IsStarted() {
|
||||
return mStarted;
|
||||
}
|
||||
|
||||
void
|
||||
AudioCallbackDriver::EnqueueStreamAndPromiseForOperation(MediaStream* aStream,
|
||||
void* aPromise,
|
||||
dom::AudioContextOperation aOperation)
|
||||
{
|
||||
MonitorAutoLock mon(mGraphImpl->GetMonitor());
|
||||
mPromisesForOperation.AppendElement(StreamAndPromiseForOperation(aStream,
|
||||
aPromise,
|
||||
aOperation));
|
||||
}
|
||||
|
||||
void AudioCallbackDriver::CompleteAudioContextOperations(AsyncCubebOperation aOperation)
|
||||
{
|
||||
nsAutoTArray<StreamAndPromiseForOperation, 1> array;
|
||||
|
||||
// We can't lock for the whole function because AudioContextOperationCompleted
|
||||
// will grab the monitor
|
||||
{
|
||||
MonitorAutoLock mon(GraphImpl()->GetMonitor());
|
||||
array.SwapElements(mPromisesForOperation);
|
||||
}
|
||||
|
||||
for (int32_t i = array.Length() - 1; i >= 0; i--) {
|
||||
StreamAndPromiseForOperation& s = array[i];
|
||||
if ((aOperation == AsyncCubebOperation::INIT &&
|
||||
s.mOperation == dom::AudioContextOperation::Resume) ||
|
||||
(aOperation == AsyncCubebOperation::SHUTDOWN &&
|
||||
s.mOperation != dom::AudioContextOperation::Resume)) {
|
||||
|
||||
GraphImpl()->AudioContextOperationCompleted(s.mStream,
|
||||
s.mPromise,
|
||||
s.mOperation);
|
||||
array.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!array.IsEmpty()) {
|
||||
MonitorAutoLock mon(GraphImpl()->GetMonitor());
|
||||
mPromisesForOperation.AppendElements(array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namepace mozilla
|
||||
|
||||
Reference in New Issue
Block a user