OLD | NEW |
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 Loading... |
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 Loading... |
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 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } | 1107 } |
1096 | 1108 |
1097 void AudioContext::decrementActiveSourceCount() | 1109 void AudioContext::decrementActiveSourceCount() |
1098 { | 1110 { |
1099 atomicDecrement(&m_activeSourceCount); | 1111 atomicDecrement(&m_activeSourceCount); |
1100 } | 1112 } |
1101 | 1113 |
1102 } // namespace WebCore | 1114 } // namespace WebCore |
1103 | 1115 |
1104 #endif // ENABLE(WEB_AUDIO) | 1116 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |