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
&) |
99 { | 100 { |
100 ASSERT(document); | |
101 ASSERT(isMainThread()); | 101 ASSERT(isMainThread()); |
102 if (s_hardwareContextCount >= MaxHardwareContexts) | 102 if (s_hardwareContextCount >= MaxHardwareContexts) |
103 return 0; | 103 return 0; |
104 | 104 |
105 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(document))); | 105 RefPtr<AudioContext> audioContext(adoptRef(new AudioContext(&document))); |
106 audioContext->suspendIfNeeded(); | 106 audioContext->suspendIfNeeded(); |
107 return audioContext.release(); | 107 return audioContext.release(); |
108 } | 108 } |
109 | 109 |
| 110 PassRefPtr<AudioContext> AudioContext::create(Document& document, unsigned numbe
rOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& es) |
| 111 { |
| 112 document.addConsoleMessage(JSMessageSource, WarningMessageLevel, "Deprecated
AudioContext constructor: use OfflineAudioContext instead"); |
| 113 return OfflineAudioContext::create(&document, numberOfChannels, numberOfFram
es, sampleRate, es); |
| 114 } |
| 115 |
110 // Constructor for rendering to the audio hardware. | 116 // Constructor for rendering to the audio hardware. |
111 AudioContext::AudioContext(Document* document) | 117 AudioContext::AudioContext(Document* document) |
112 : ActiveDOMObject(document) | 118 : ActiveDOMObject(document) |
113 , m_isStopScheduled(false) | 119 , m_isStopScheduled(false) |
114 , m_isInitialized(false) | 120 , m_isInitialized(false) |
115 , m_isAudioThreadFinished(false) | 121 , m_isAudioThreadFinished(false) |
116 , m_destinationNode(0) | 122 , m_destinationNode(0) |
117 , m_isDeletionScheduled(false) | 123 , m_isDeletionScheduled(false) |
118 , m_automaticPullNodesNeedUpdating(false) | 124 , m_automaticPullNodesNeedUpdating(false) |
119 , m_connectionCount(0) | 125 , m_connectionCount(0) |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } | 1101 } |
1096 | 1102 |
1097 void AudioContext::decrementActiveSourceCount() | 1103 void AudioContext::decrementActiveSourceCount() |
1098 { | 1104 { |
1099 atomicDecrement(&m_activeSourceCount); | 1105 atomicDecrement(&m_activeSourceCount); |
1100 } | 1106 } |
1101 | 1107 |
1102 } // namespace WebCore | 1108 } // namespace WebCore |
1103 | 1109 |
1104 #endif // ENABLE(WEB_AUDIO) | 1110 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |