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