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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 ChannelSplitterNode* createChannelSplitter(ExceptionState&); | 153 ChannelSplitterNode* createChannelSplitter(ExceptionState&); |
154 ChannelSplitterNode* createChannelSplitter(size_t numberOfOutputs, Exception State&); | 154 ChannelSplitterNode* createChannelSplitter(size_t numberOfOutputs, Exception State&); |
155 ChannelMergerNode* createChannelMerger(ExceptionState&); | 155 ChannelMergerNode* createChannelMerger(ExceptionState&); |
156 ChannelMergerNode* createChannelMerger(size_t numberOfInputs, ExceptionState &); | 156 ChannelMergerNode* createChannelMerger(size_t numberOfInputs, ExceptionState &); |
157 OscillatorNode* createOscillator(ExceptionState&); | 157 OscillatorNode* createOscillator(ExceptionState&); |
158 PeriodicWave* createPeriodicWave(DOMFloat32Array* real, DOMFloat32Array* ima g, ExceptionState&); | 158 PeriodicWave* createPeriodicWave(DOMFloat32Array* real, DOMFloat32Array* ima g, ExceptionState&); |
159 | 159 |
160 // Close | 160 // Close |
161 virtual ScriptPromise closeContext(ScriptState*) = 0; | 161 virtual ScriptPromise closeContext(ScriptState*) = 0; |
162 | 162 |
163 // Suspend/Resume | 163 // Suspend for online audio context. |
164 virtual ScriptPromise suspendContext(ScriptState*) = 0; | 164 virtual ScriptPromise suspendContext(ScriptState*) = 0; |
165 | |
166 // Suspend for offline audio context. | |
167 virtual ScriptPromise suspendContext(ScriptState*, double) = 0; | |
168 | |
169 // Resume | |
165 virtual ScriptPromise resumeContext(ScriptState*) = 0; | 170 virtual ScriptPromise resumeContext(ScriptState*) = 0; |
166 | 171 |
167 // When a source node has started processing and needs to be protected, | 172 // When a source node has started processing and needs to be protected, |
168 // this method tells the context to protect the node. | 173 // this method tells the context to protect the node. |
169 // | 174 // |
170 // The context itself keeps a reference to all source nodes. The source | 175 // The context itself keeps a reference to all source nodes. The source |
171 // nodes, then reference all nodes they're connected to. In turn, these | 176 // nodes, then reference all nodes they're connected to. In turn, these |
172 // nodes reference all nodes they're connected to. All nodes are ultimately | 177 // nodes reference all nodes they're connected to. All nodes are ultimately |
173 // connected to the AudioDestinationNode. When the context release a source | 178 // connected to the AudioDestinationNode. When the context release a source |
174 // node, it will be deactivated from the rendering graph along with all | 179 // node, it will be deactivated from the rendering graph along with all |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 #endif | 218 #endif |
214 using AutoLocker = DeferredTaskHandler::AutoLocker; | 219 using AutoLocker = DeferredTaskHandler::AutoLocker; |
215 | 220 |
216 // Returns the maximum numuber of channels we can support. | 221 // Returns the maximum numuber of channels we can support. |
217 static unsigned maxNumberOfChannels() { return MaxNumberOfChannels;} | 222 static unsigned maxNumberOfChannels() { return MaxNumberOfChannels;} |
218 | 223 |
219 // EventTarget | 224 // EventTarget |
220 const AtomicString& interfaceName() const final; | 225 const AtomicString& interfaceName() const final; |
221 ExecutionContext* executionContext() const final; | 226 ExecutionContext* executionContext() const final; |
222 | 227 |
223 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); | |
224 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 228 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
225 | 229 |
226 void startRendering(); | 230 void startRendering(); |
227 void fireCompletionEvent(); | |
228 void notifyStateChange(); | 231 void notifyStateChange(); |
229 | 232 |
233 // TODO(hongchan): move this to OfflineAudioContext. | |
234 AudioBuffer* renderTarget() const { return m_renderTarget.get(); } | |
235 | |
230 // A context is considered closed if: | 236 // A context is considered closed if: |
231 // - closeContext() has been called. | 237 // - closeContext() has been called. |
232 // - it has been stopped by its execution context. | 238 // - it has been stopped by its execution context. |
233 virtual bool isContextClosed() const { return m_isCleared; } | 239 virtual bool isContextClosed() const { return m_isCleared; } |
234 | 240 |
235 // Get the security origin for this audio context. | 241 // Get the security origin for this audio context. |
236 SecurityOrigin* securityOrigin() const; | 242 SecurityOrigin* securityOrigin() const; |
237 | 243 |
238 protected: | 244 protected: |
239 explicit AbstractAudioContext(Document*); | 245 explicit AbstractAudioContext(Document*); |
240 AbstractAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFr ames, float sampleRate); | 246 AbstractAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFr ames, float sampleRate); |
241 | 247 |
242 void setContextState(AudioContextState); | 248 void setContextState(AudioContextState); |
243 virtual void didClose() {} | 249 virtual void didClose() {} |
244 void uninitialize(); | 250 void uninitialize(); |
245 | 251 |
246 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; | 252 // RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; |
tkent
2015/07/16 00:33:43
Remove this line.
hongchan
2015/07/16 16:22:18
Done.
| |
247 | 253 |
248 // FIXME(dominicc): Move m_resumeResolvers to AudioContext, because only | 254 // FIXME(dominicc): Move m_resumeResolvers to AudioContext, because only |
249 // it creates these Promises. | 255 // it creates these Promises. |
250 // Vector of promises created by resume(). It takes time to handle them, so we collect all of | 256 // Vector of promises created by resume(). It takes time to handle them, so we collect all of |
251 // the promises here until they can be resolved or rejected. | 257 // the promises here until they can be resolved or rejected. |
252 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolver s; | 258 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolver s; |
253 private: | 259 private: |
254 void initialize(); | 260 void initialize(); |
255 | 261 |
256 bool m_isCleared; | 262 bool m_isCleared; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 // time and the audio context process loop is very fast, so we don't want to call resolve an | 299 // time and the audio context process loop is very fast, so we don't want to call resolve an |
294 // excessive number of times. | 300 // excessive number of times. |
295 bool m_isResolvingResumePromises; | 301 bool m_isResolvingResumePromises; |
296 | 302 |
297 unsigned m_connectionCount; | 303 unsigned m_connectionCount; |
298 | 304 |
299 // Graph locking. | 305 // Graph locking. |
300 bool m_didInitializeContextGraphMutex; | 306 bool m_didInitializeContextGraphMutex; |
301 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; | 307 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; |
302 | 308 |
309 // For offline audio context. | |
310 // TODO(hongchan): move this to OfflineAudioContext class. | |
303 Member<AudioBuffer> m_renderTarget; | 311 Member<AudioBuffer> m_renderTarget; |
304 | 312 |
305 // The state of the AbstractAudioContext. | 313 // The state of the AbstractAudioContext. |
306 AudioContextState m_contextState; | 314 AudioContextState m_contextState; |
307 | 315 |
308 AsyncAudioDecoder m_audioDecoder; | 316 AsyncAudioDecoder m_audioDecoder; |
309 | 317 |
310 // Tries to handle AudioBufferSourceNodes that were started but became disco nnected or was never | 318 // Tries to handle AudioBufferSourceNodes that were started but became disco nnected or was never |
311 // connected. Because these never get pulled anymore, they will stay around forever. So if we | 319 // connected. Because these never get pulled anymore, they will stay around forever. So if we |
312 // can, try to stop them so they can be collected. | 320 // can, try to stop them so they can be collected. |
313 void handleStoppableSourceNodes(); | 321 void handleStoppableSourceNodes(); |
314 | 322 |
315 // This is considering 32 is large enough for multiple channels audio. | 323 // This is considering 32 is large enough for multiple channels audio. |
316 // It is somewhat arbitrary and could be increased if necessary. | 324 // It is somewhat arbitrary and could be increased if necessary. |
317 enum { MaxNumberOfChannels = 32 }; | 325 enum { MaxNumberOfChannels = 32 }; |
318 }; | 326 }; |
319 | 327 |
320 } // namespace blink | 328 } // namespace blink |
321 | 329 |
322 #endif // AbstractAudioContext_h | 330 #endif // AbstractAudioContext_h |
OLD | NEW |