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

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

Issue 27037002: Get rid of custom bindings for AudioContext's constructor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 months 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
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioContext.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioContext.cpp
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp
index 884d95bd3025cf92ea50f9884d75e07a6c81adb3..a7c6ce2df26d1bdd157bf1f31f3c372a2288d6f8 100644
--- a/Source/modules/webaudio/AudioContext.cpp
+++ b/Source/modules/webaudio/AudioContext.cpp
@@ -58,6 +58,7 @@
#include "modules/webaudio/MediaStreamAudioDestinationNode.h"
#include "modules/webaudio/MediaStreamAudioSourceNode.h"
#include "modules/webaudio/OfflineAudioCompletionEvent.h"
+#include "modules/webaudio/OfflineAudioContext.h"
#include "modules/webaudio/OfflineAudioDestinationNode.h"
#include "modules/webaudio/OscillatorNode.h"
#include "modules/webaudio/PannerNode.h"
@@ -95,18 +96,29 @@ bool AudioContext::isSampleRateRangeGood(float sampleRate)
const unsigned MaxHardwareContexts = 4;
unsigned AudioContext::s_hardwareContextCount = 0;
-PassRefPtr<AudioContext> AudioContext::create(Document* document)
+PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionState& es)
{
- ASSERT(document);
ASSERT(isMainThread());
- if (s_hardwareContextCount >= MaxHardwareContexts)
+ if (s_hardwareContextCount >= MaxHardwareContexts) {
+ es.throwDOMException(
+ SyntaxError,
+ ExceptionMessages::failedToConstruct(
+ "AudioContext",
+ "number of hardware contexts reached maximum (" + String::number(MaxHardwareContexts) + ")."));
return 0;
+ }
- RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(document)));
+ RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document)));
audioContext->suspendIfNeeded();
return audioContext.release();
}
+PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& es)
+{
+ document.addConsoleMessage(JSMessageSource, WarningMessageLevel, "Deprecated AudioContext constructor: use OfflineAudioContext instead");
+ return OfflineAudioContext::create(&document, numberOfChannels, numberOfFrames, sampleRate, es);
+}
+
// Constructor for rendering to the audio hardware.
AudioContext::AudioContext(Document* document)
: ActiveDOMObject(document)
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioContext.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698