Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioContext.cpp

Issue 2501863003: Support for AudioContextOptions latencyHint. (Closed)
Patch Set: Add baseLatency and fix use of hardwareSampleRate. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
index 920678225ca55b9c22d8908fa4de6b3d7bce0f17..623482ff14f2f9da5b43f1d2c99fa078613008ac 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
@@ -11,8 +11,10 @@
#include "core/dom/ExceptionCode.h"
#include "core/frame/UseCounter.h"
#include "modules/webaudio/AudioBufferCallback.h"
+#include "modules/webaudio/AudioContextOptions.h"
#include "platform/Histogram.h"
#include "platform/audio/AudioUtilities.h"
+#include "public/platform/WebAudioLatencyHint.h"
#if DEBUG_AUDIONODE_REFERENCES
#include <stdio.h>
@@ -27,6 +29,26 @@ static unsigned s_hardwareContextCount = 0;
static unsigned s_contextId = 0;
AudioContext* AudioContext::create(Document& document,
+ const AudioContextOptions& contextOptions,
+ ExceptionState& exceptionState) {
+ WebAudioLatencyHint::Category latencyCategory;
o1ka 2016/11/30 11:46:26 This code looks like it worth a helper function.
Andrew MacPherson 2016/12/01 12:11:56 Done.
+ if (contextOptions.latencyHint() == "interactive") {
+ latencyCategory = WebAudioLatencyHint::CategoryInteractive;
+ } else if (contextOptions.latencyHint() == "balanced") {
+ latencyCategory = WebAudioLatencyHint::CategoryBalanced;
+ } else if (contextOptions.latencyHint() == "playback") {
+ latencyCategory = WebAudioLatencyHint::CategoryPlayback;
+ } else {
+ NOTREACHED();
+ latencyCategory = WebAudioLatencyHint::CategoryInteractive;
+ }
+
+ WebAudioLatencyHint latencyHint(latencyCategory);
o1ka 2016/11/30 11:46:26 Why do you need a local for that?
Andrew MacPherson 2016/12/01 12:11:56 That was a mistake but based on rtoy@'s suggestion
+ return AudioContext::create(document, latencyHint, exceptionState);
+}
+
+AudioContext* AudioContext::create(Document& document,
+ const WebAudioLatencyHint& latencyHint,
ExceptionState& exceptionState) {
DCHECK(isMainThread());
@@ -41,7 +63,7 @@ AudioContext* AudioContext::create(Document& document,
return nullptr;
}
- AudioContext* audioContext = new AudioContext(document);
+ AudioContext* audioContext = new AudioContext(document, latencyHint);
audioContext->suspendIfNeeded();
if (!AudioUtilities::isValidAudioBufferSampleRate(
@@ -83,8 +105,9 @@ AudioContext* AudioContext::create(Document& document,
return audioContext;
}
-AudioContext::AudioContext(Document& document)
- : BaseAudioContext(&document), m_contextId(s_contextId++) {}
+AudioContext::AudioContext(Document& document,
+ const WebAudioLatencyHint& latencyHint)
+ : BaseAudioContext(&document, latencyHint), m_contextId(s_contextId++) {}
AudioContext::~AudioContext() {
#if DEBUG_AUDIONODE_REFERENCES

Powered by Google App Engine
This is Rietveld 408576698