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