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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 size_t currentSampleFrame() const; | 230 size_t currentSampleFrame() const; |
231 double currentTime() const; | 231 double currentTime() const; |
232 | 232 |
233 float sampleRate() const { return m_destinationNode ? m_destinationNode->han
dler().sampleRate() : 0; } | 233 float sampleRate() const { return m_destinationNode ? m_destinationNode->han
dler().sampleRate() : 0; } |
234 | 234 |
235 String state() const; | 235 String state() const; |
236 | 236 |
237 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); | 237 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); |
238 | 238 |
239 // Asynchronous audio file data decoding. | 239 // Asynchronous audio file data decoding. |
240 ScriptPromise decodeAudioData(ScriptState*, DOMArrayBuffer*, AudioBufferCall
back*, AudioBufferCallback*, ExceptionState&); | 240 void decodeAudioData(DOMArrayBuffer*, AudioBufferCallback*, AudioBufferCallb
ack*, ExceptionState&); |
241 | 241 |
242 AudioListener* listener() { return m_listener.get(); } | 242 AudioListener* listener() { return m_listener.get(); } |
243 | 243 |
244 // The AudioNode create methods are called on the main thread (from JavaScri
pt). | 244 // The AudioNode create methods are called on the main thread (from JavaScri
pt). |
245 AudioBufferSourceNode* createBufferSource(ExceptionState&); | 245 AudioBufferSourceNode* createBufferSource(ExceptionState&); |
246 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); | 246 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); |
247 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); | 247 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); |
248 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); | 248 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); |
249 GainNode* createGain(ExceptionState&); | 249 GainNode* createGain(ExceptionState&); |
250 BiquadFilterNode* createBiquadFilter(ExceptionState&); | 250 BiquadFilterNode* createBiquadFilter(ExceptionState&); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // A context is considered closed if closeContext() has been called, even if
the audio HW has | 341 // A context is considered closed if closeContext() has been called, even if
the audio HW has |
342 // not yet been stopped. It will be stopped eventually. | 342 // not yet been stopped. It will be stopped eventually. |
343 bool isContextClosed() const { return m_closeResolver; } | 343 bool isContextClosed() const { return m_closeResolver; } |
344 | 344 |
345 static unsigned s_hardwareContextCount; | 345 static unsigned s_hardwareContextCount; |
346 static unsigned s_contextId; | 346 static unsigned s_contextId; |
347 | 347 |
348 // Get the security origin for this audio context. | 348 // Get the security origin for this audio context. |
349 SecurityOrigin* securityOrigin() const; | 349 SecurityOrigin* securityOrigin() const; |
350 | 350 |
351 void removeAudioDecoderResolver(ScriptPromiseResolver*); | |
352 protected: | 351 protected: |
353 explicit AudioContext(Document*); | 352 explicit AudioContext(Document*); |
354 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); | 353 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); |
355 | 354 |
356 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; | 355 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; |
357 private: | 356 private: |
358 void initialize(); | 357 void initialize(); |
359 void uninitialize(); | 358 void uninitialize(); |
360 | 359 |
361 // ExecutionContext calls stop twice. | 360 // ExecutionContext calls stop twice. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 427 |
429 Member<AudioBuffer> m_renderTarget; | 428 Member<AudioBuffer> m_renderTarget; |
430 | 429 |
431 bool m_isOfflineContext; | 430 bool m_isOfflineContext; |
432 | 431 |
433 // The state of the AudioContext. | 432 // The state of the AudioContext. |
434 AudioContextState m_contextState; | 433 AudioContextState m_contextState; |
435 void setContextState(AudioContextState); | 434 void setContextState(AudioContextState); |
436 | 435 |
437 AsyncAudioDecoder m_audioDecoder; | 436 AsyncAudioDecoder m_audioDecoder; |
438 // A vector of the ScriptPromiseResolvers the decodeAudioData method uses. | |
439 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_audioDecoderRe
solvers; | |
440 | 437 |
441 // The Promise that is returned by close(); | 438 // The Promise that is returned by close(); |
442 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; | 439 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; |
443 | 440 |
444 // Follows the destination's currentSampleFrame, but might be slightly behin
d due to locking. | 441 // Follows the destination's currentSampleFrame, but might be slightly behin
d due to locking. |
445 size_t m_cachedSampleFrame; | 442 size_t m_cachedSampleFrame; |
446 | 443 |
447 // When a context is closed, the sample rate is cleared. But decodeAudioDat
a can be called | |
448 // after the context has been closed and it needs the sample rate. When the
context is closed, | |
449 // the sample rate is saved here. | |
450 float m_closedContextSampleRate; | |
451 | |
452 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never | 444 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never |
453 // connected. Because these never get pulled anymore, they will stay around
forever. So if we | 445 // connected. Because these never get pulled anymore, they will stay around
forever. So if we |
454 // can, try to stop them so they can be collected. | 446 // can, try to stop them so they can be collected. |
455 void handleStoppableSourceNodes(); | 447 void handleStoppableSourceNodes(); |
456 | 448 |
457 // This is considering 32 is large enough for multiple channels audio. | 449 // This is considering 32 is large enough for multiple channels audio. |
458 // It is somewhat arbitrary and could be increased if necessary. | 450 // It is somewhat arbitrary and could be increased if necessary. |
459 enum { MaxNumberOfChannels = 32 }; | 451 enum { MaxNumberOfChannels = 32 }; |
460 | 452 |
461 unsigned m_contextId; | 453 unsigned m_contextId; |
462 }; | 454 }; |
463 | 455 |
464 } // namespace blink | 456 } // namespace blink |
465 | 457 |
466 #endif // AudioContext_h | 458 #endif // AudioContext_h |
OLD | NEW |