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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioContext.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "modules/webaudio/ChannelSplitterNode.h" 51 #include "modules/webaudio/ChannelSplitterNode.h"
52 #include "modules/webaudio/ConvolverNode.h" 52 #include "modules/webaudio/ConvolverNode.h"
53 #include "modules/webaudio/DefaultAudioDestinationNode.h" 53 #include "modules/webaudio/DefaultAudioDestinationNode.h"
54 #include "modules/webaudio/DelayNode.h" 54 #include "modules/webaudio/DelayNode.h"
55 #include "modules/webaudio/DynamicsCompressorNode.h" 55 #include "modules/webaudio/DynamicsCompressorNode.h"
56 #include "modules/webaudio/GainNode.h" 56 #include "modules/webaudio/GainNode.h"
57 #include "modules/webaudio/MediaElementAudioSourceNode.h" 57 #include "modules/webaudio/MediaElementAudioSourceNode.h"
58 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" 58 #include "modules/webaudio/MediaStreamAudioDestinationNode.h"
59 #include "modules/webaudio/MediaStreamAudioSourceNode.h" 59 #include "modules/webaudio/MediaStreamAudioSourceNode.h"
60 #include "modules/webaudio/OfflineAudioCompletionEvent.h" 60 #include "modules/webaudio/OfflineAudioCompletionEvent.h"
61 #include "modules/webaudio/OfflineAudioContext.h"
61 #include "modules/webaudio/OfflineAudioDestinationNode.h" 62 #include "modules/webaudio/OfflineAudioDestinationNode.h"
62 #include "modules/webaudio/OscillatorNode.h" 63 #include "modules/webaudio/OscillatorNode.h"
63 #include "modules/webaudio/PannerNode.h" 64 #include "modules/webaudio/PannerNode.h"
64 #include "modules/webaudio/PeriodicWave.h" 65 #include "modules/webaudio/PeriodicWave.h"
65 #include "modules/webaudio/ScriptProcessorNode.h" 66 #include "modules/webaudio/ScriptProcessorNode.h"
66 #include "modules/webaudio/WaveShaperNode.h" 67 #include "modules/webaudio/WaveShaperNode.h"
67 68
68 #if DEBUG_AUDIONODE_REFERENCES 69 #if DEBUG_AUDIONODE_REFERENCES
69 #include <stdio.h> 70 #include <stdio.h>
70 #endif 71 #endif
(...skipping 17 matching lines...) Expand all
88 { 89 {
89 // FIXME: It would be nice if the minimum sample-rate could be less than 44. 1KHz, 90 // FIXME: It would be nice if the minimum sample-rate could be less than 44. 1KHz,
90 // but that will require some fixes in HRTFPanner::fftSizeForSampleRate(), a nd some testing there. 91 // but that will require some fixes in HRTFPanner::fftSizeForSampleRate(), a nd some testing there.
91 return sampleRate >= 44100 && sampleRate <= 96000; 92 return sampleRate >= 44100 && sampleRate <= 96000;
92 } 93 }
93 94
94 // Don't allow more than this number of simultaneous AudioContexts talking to ha rdware. 95 // Don't allow more than this number of simultaneous AudioContexts talking to ha rdware.
95 const unsigned MaxHardwareContexts = 4; 96 const unsigned MaxHardwareContexts = 4;
96 unsigned AudioContext::s_hardwareContextCount = 0; 97 unsigned AudioContext::s_hardwareContextCount = 0;
97 98
98 PassRefPtr<AudioContext> AudioContext::create(Document* document) 99 PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionState & es)
99 { 100 {
100 ASSERT(document);
101 ASSERT(isMainThread()); 101 ASSERT(isMainThread());
102 if (s_hardwareContextCount >= MaxHardwareContexts) 102 if (s_hardwareContextCount >= MaxHardwareContexts) {
103 es.throwDOMException(
104 SyntaxError,
105 ExceptionMessages::failedToConstruct(
106 "AudioContext",
107 "number of hardware contexts reached maximum (" + String::number (MaxHardwareContexts) + ")."));
103 return 0; 108 return 0;
109 }
104 110
105 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(document))); 111 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document)));
106 audioContext->suspendIfNeeded(); 112 audioContext->suspendIfNeeded();
107 return audioContext.release(); 113 return audioContext.release();
108 } 114 }
109 115
116 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& es)
117 {
118 document.addConsoleMessage(JSMessageSource, WarningMessageLevel, "Deprecated AudioContext constructor: use OfflineAudioContext instead");
119 return OfflineAudioContext::create(&document, numberOfChannels, numberOfFram es, sampleRate, es);
120 }
121
110 // Constructor for rendering to the audio hardware. 122 // Constructor for rendering to the audio hardware.
111 AudioContext::AudioContext(Document* document) 123 AudioContext::AudioContext(Document* document)
112 : ActiveDOMObject(document) 124 : ActiveDOMObject(document)
113 , m_isStopScheduled(false) 125 , m_isStopScheduled(false)
114 , m_isInitialized(false) 126 , m_isInitialized(false)
115 , m_isAudioThreadFinished(false) 127 , m_isAudioThreadFinished(false)
116 , m_destinationNode(0) 128 , m_destinationNode(0)
117 , m_isDeletionScheduled(false) 129 , m_isDeletionScheduled(false)
118 , m_automaticPullNodesNeedUpdating(false) 130 , m_automaticPullNodesNeedUpdating(false)
119 , m_connectionCount(0) 131 , m_connectionCount(0)
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1109 }
1098 1110
1099 void AudioContext::decrementActiveSourceCount() 1111 void AudioContext::decrementActiveSourceCount()
1100 { 1112 {
1101 atomicDecrement(&m_activeSourceCount); 1113 atomicDecrement(&m_activeSourceCount);
1102 } 1114 }
1103 1115
1104 } // namespace WebCore 1116 } // namespace WebCore
1105 1117
1106 #endif // ENABLE(WEB_AUDIO) 1118 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« 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