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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 size_t currentSampleFrame() const; | 117 size_t currentSampleFrame() const; |
118 double currentTime() const; | 118 double currentTime() const; |
119 | 119 |
120 float sampleRate() const { return m_destinationNode ? m_destinationNode->sam
pleRate() : 0; } | 120 float sampleRate() const { return m_destinationNode ? m_destinationNode->sam
pleRate() : 0; } |
121 | 121 |
122 String state() const; | 122 String state() const; |
123 | 123 |
124 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); | 124 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); |
125 | 125 |
126 // Asynchronous audio file data decoding. | 126 // Asynchronous audio file data decoding. |
127 void decodeAudioData(DOMArrayBuffer*, AudioBufferCallback*, AudioBufferCallb
ack*, ExceptionState&); | 127 ScriptPromise decodeAudioData(ScriptState*, DOMArrayBuffer*, AudioBufferCall
back*, AudioBufferCallback*, ExceptionState&); |
128 | 128 |
129 AudioListener* listener() { return m_listener.get(); } | 129 AudioListener* listener() { return m_listener.get(); } |
130 | 130 |
131 // The AudioNode create methods are called on the main thread (from JavaScri
pt). | 131 // The AudioNode create methods are called on the main thread (from JavaScri
pt). |
132 AudioBufferSourceNode* createBufferSource(ExceptionState&); | 132 AudioBufferSourceNode* createBufferSource(ExceptionState&); |
133 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); | 133 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); |
134 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); | 134 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); |
135 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); | 135 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); |
136 GainNode* createGain(ExceptionState&); | 136 GainNode* createGain(ExceptionState&); |
137 BiquadFilterNode* createBiquadFilter(ExceptionState&); | 137 BiquadFilterNode* createBiquadFilter(ExceptionState&); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // A context is considered closed if closeContext() has been called, even if
the audio HW has | 276 // A context is considered closed if closeContext() has been called, even if
the audio HW has |
277 // not yet been stopped. It will be stopped eventually. | 277 // not yet been stopped. It will be stopped eventually. |
278 bool isContextClosed() const { return m_closeResolver; } | 278 bool isContextClosed() const { return m_closeResolver; } |
279 | 279 |
280 static unsigned s_hardwareContextCount; | 280 static unsigned s_hardwareContextCount; |
281 static unsigned s_contextId; | 281 static unsigned s_contextId; |
282 | 282 |
283 // Get the security origin for this audio context. | 283 // Get the security origin for this audio context. |
284 SecurityOrigin* securityOrigin() const; | 284 SecurityOrigin* securityOrigin() const; |
285 | 285 |
| 286 void removeAudioDecoderResolver(ScriptPromiseResolver*); |
286 protected: | 287 protected: |
287 explicit AudioContext(Document*); | 288 explicit AudioContext(Document*); |
288 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); | 289 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); |
289 | 290 |
290 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; | 291 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; |
291 private: | 292 private: |
292 void initialize(); | 293 void initialize(); |
293 void uninitialize(); | 294 void uninitialize(); |
294 | 295 |
295 // ExecutionContext calls stop twice. | 296 // ExecutionContext calls stop twice. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 411 |
411 Member<AudioBuffer> m_renderTarget; | 412 Member<AudioBuffer> m_renderTarget; |
412 | 413 |
413 bool m_isOfflineContext; | 414 bool m_isOfflineContext; |
414 | 415 |
415 // The state of the AudioContext. | 416 // The state of the AudioContext. |
416 AudioContextState m_contextState; | 417 AudioContextState m_contextState; |
417 void setContextState(AudioContextState); | 418 void setContextState(AudioContextState); |
418 | 419 |
419 AsyncAudioDecoder m_audioDecoder; | 420 AsyncAudioDecoder m_audioDecoder; |
| 421 // A vector of the ScriptPromiseResolvers the decodeAudioData method uses. |
| 422 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_audioDecoderRe
solvers; |
420 | 423 |
421 // Collection of nodes where the channel count mode has changed. We want the
channel count mode | 424 // Collection of nodes where the channel count mode has changed. We want the
channel count mode |
422 // to change in the pre- or post-rendering phase so as not to disturb the ru
nning audio thread. | 425 // to change in the pre- or post-rendering phase so as not to disturb the ru
nning audio thread. |
423 GC_PLUGIN_IGNORE("http://crbug.com/404527") | 426 GC_PLUGIN_IGNORE("http://crbug.com/404527") |
424 HashSet<AudioNode*> m_deferredCountModeChange; | 427 HashSet<AudioNode*> m_deferredCountModeChange; |
425 | 428 |
426 // The Promise that is returned by close(); | 429 // The Promise that is returned by close(); |
427 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; | 430 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; |
428 | 431 |
429 // Follows the destination's currentSampleFrame, but might be slightly behin
d due to locking. | 432 // Follows the destination's currentSampleFrame, but might be slightly behin
d due to locking. |
430 size_t m_cachedSampleFrame; | 433 size_t m_cachedSampleFrame; |
431 | 434 |
| 435 // When a context is closed, the sample rate is cleared. But decodeAudioDat
a can be called |
| 436 // after the context has been closed and it needs the sample rate. When the
context is closed, |
| 437 // the sample rate is saved here. |
| 438 float m_closedContextSampleRate; |
| 439 |
432 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never | 440 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never |
433 // connected. Because these never get pulled anymore, they will stay around
forever. So if we | 441 // connected. Because these never get pulled anymore, they will stay around
forever. So if we |
434 // can, try to stop them so they can be collected. | 442 // can, try to stop them so they can be collected. |
435 void handleStoppableSourceNodes(); | 443 void handleStoppableSourceNodes(); |
436 | 444 |
437 // This is considering 32 is large enough for multiple channels audio. | 445 // This is considering 32 is large enough for multiple channels audio. |
438 // It is somewhat arbitrary and could be increased if necessary. | 446 // It is somewhat arbitrary and could be increased if necessary. |
439 enum { MaxNumberOfChannels = 32 }; | 447 enum { MaxNumberOfChannels = 32 }; |
440 | 448 |
441 unsigned m_contextId; | 449 unsigned m_contextId; |
442 }; | 450 }; |
443 | 451 |
444 } // namespace blink | 452 } // namespace blink |
445 | 453 |
446 #endif // AudioContext_h | 454 #endif // AudioContext_h |
OLD | NEW |