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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #ifndef AbstractAudioContext_h | 25 #ifndef AbstractAudioContext_h |
26 #define AbstractAudioContext_h | 26 #define AbstractAudioContext_h |
27 | 27 |
| 28 #include "bindings/core/v8/ActiveScriptWrappable.h" |
28 #include "bindings/core/v8/ScriptPromise.h" | 29 #include "bindings/core/v8/ScriptPromise.h" |
29 #include "bindings/core/v8/ScriptPromiseResolver.h" | 30 #include "bindings/core/v8/ScriptPromiseResolver.h" |
30 #include "core/dom/ActiveDOMObject.h" | 31 #include "core/dom/ActiveDOMObject.h" |
31 #include "core/dom/DOMTypedArray.h" | 32 #include "core/dom/DOMTypedArray.h" |
32 #include "core/events/EventListener.h" | 33 #include "core/events/EventListener.h" |
33 #include "modules/EventTargetModules.h" | 34 #include "modules/EventTargetModules.h" |
34 #include "modules/ModulesExport.h" | 35 #include "modules/ModulesExport.h" |
35 #include "modules/webaudio/AsyncAudioDecoder.h" | 36 #include "modules/webaudio/AsyncAudioDecoder.h" |
36 #include "modules/webaudio/AudioDestinationNode.h" | 37 #include "modules/webaudio/AudioDestinationNode.h" |
37 #include "modules/webaudio/DeferredTaskHandler.h" | 38 #include "modules/webaudio/DeferredTaskHandler.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 class ScriptProcessorNode; | 75 class ScriptProcessorNode; |
75 class ScriptPromiseResolver; | 76 class ScriptPromiseResolver; |
76 class ScriptState; | 77 class ScriptState; |
77 class SecurityOrigin; | 78 class SecurityOrigin; |
78 class StereoPannerNode; | 79 class StereoPannerNode; |
79 class WaveShaperNode; | 80 class WaveShaperNode; |
80 | 81 |
81 // AbstractAudioContext is the cornerstone of the web audio API and all AudioNod
es are created from it. | 82 // AbstractAudioContext is the cornerstone of the web audio API and all AudioNod
es are created from it. |
82 // For thread safety between the audio thread and the main thread, it has a rend
ering graph locking mechanism. | 83 // For thread safety between the audio thread and the main thread, it has a rend
ering graph locking mechanism. |
83 | 84 |
84 class MODULES_EXPORT AbstractAudioContext : public RefCountedGarbageCollectedEve
ntTargetWithInlineData<AbstractAudioContext>, public ActiveDOMObject { | 85 class MODULES_EXPORT AbstractAudioContext : public RefCountedGarbageCollectedEve
ntTargetWithInlineData<AbstractAudioContext>, public ActiveScriptWrappable, publ
ic ActiveDOMObject { |
85 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(AbstractAudioContext); | 86 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(AbstractAudioContext); |
86 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AbstractAudioContext); | 87 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AbstractAudioContext); |
87 DEFINE_WRAPPERTYPEINFO(); | 88 DEFINE_WRAPPERTYPEINFO(); |
88 public: | 89 public: |
89 // The state of an audio context. On creation, the state is Suspended. The
state is Running if | 90 // The state of an audio context. On creation, the state is Suspended. The
state is Running if |
90 // audio is being processed (audio graph is being pulled for data). The stat
e is Closed if the | 91 // audio is being processed (audio graph is being pulled for data). The stat
e is Closed if the |
91 // audio context has been closed. The valid transitions are from Suspended
to either Running or | 92 // audio context has been closed. The valid transitions are from Suspended
to either Running or |
92 // Closed; Running to Suspended or Closed. Once Closed, there are no valid t
ransitions. | 93 // Closed; Running to Suspended or Closed. Once Closed, there are no valid t
ransitions. |
93 enum AudioContextState { | 94 enum AudioContextState { |
94 Suspended, | 95 Suspended, |
(...skipping 10 matching lines...) Expand all Loading... |
105 | 106 |
106 // Is the destination node initialized and ready to handle audio? | 107 // Is the destination node initialized and ready to handle audio? |
107 bool isDestinationInitialized() const | 108 bool isDestinationInitialized() const |
108 { | 109 { |
109 AudioDestinationNode* dest = destination(); | 110 AudioDestinationNode* dest = destination(); |
110 return dest ? dest->audioDestinationHandler().isInitialized() : false; | 111 return dest ? dest->audioDestinationHandler().isInitialized() : false; |
111 } | 112 } |
112 | 113 |
113 // Document notification | 114 // Document notification |
114 void stop() final; | 115 void stop() final; |
115 bool hasPendingActivity() const override; | 116 bool hasPendingActivity() const final; |
116 | 117 |
117 AudioDestinationNode* destination() const { return m_destinationNode.get();
} | 118 AudioDestinationNode* destination() const { return m_destinationNode.get();
} |
118 | 119 |
119 size_t currentSampleFrame() const | 120 size_t currentSampleFrame() const |
120 { | 121 { |
121 return m_destinationNode ? m_destinationNode->audioDestinationHandler().
currentSampleFrame() : 0; | 122 return m_destinationNode ? m_destinationNode->audioDestinationHandler().
currentSampleFrame() : 0; |
122 } | 123 } |
123 | 124 |
124 double currentTime() const | 125 double currentTime() const |
125 { | 126 { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 Member<PeriodicWave> m_periodicWaveTriangle; | 349 Member<PeriodicWave> m_periodicWaveTriangle; |
349 | 350 |
350 // This is considering 32 is large enough for multiple channels audio. | 351 // This is considering 32 is large enough for multiple channels audio. |
351 // It is somewhat arbitrary and could be increased if necessary. | 352 // It is somewhat arbitrary and could be increased if necessary. |
352 enum { MaxNumberOfChannels = 32 }; | 353 enum { MaxNumberOfChannels = 32 }; |
353 }; | 354 }; |
354 | 355 |
355 } // namespace blink | 356 } // namespace blink |
356 | 357 |
357 #endif // AbstractAudioContext_h | 358 #endif // AbstractAudioContext_h |
OLD | NEW |