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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 AudioContextState contextState() const { return m_contextState; } | 137 AudioContextState contextState() const { return m_contextState; } |
138 | 138 |
139 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); | 139 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); |
140 | 140 |
141 // Asynchronous audio file data decoding. | 141 // Asynchronous audio file data decoding. |
142 ScriptPromise decodeAudioData(ScriptState*, DOMArrayBuffer* audioData, Audio
BufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionSt
ate&); | 142 ScriptPromise decodeAudioData(ScriptState*, DOMArrayBuffer* audioData, Audio
BufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionSt
ate&); |
143 | 143 |
144 // Handles the promise and callbacks when |decodeAudioData| is finished deco
ding. | 144 // Handles the promise and callbacks when |decodeAudioData| is finished deco
ding. |
145 void handleDecodeAudioData(AudioBuffer*, ScriptPromiseResolver*, AudioBuffer
Callback* successCallback, AudioBufferCallback* errorCallback); | 145 void handleDecodeAudioData(AudioBuffer*, ScriptPromiseResolver*, AudioBuffer
Callback* successCallback, AudioBufferCallback* errorCallback); |
146 | 146 |
147 AudioListener* listener() { return m_listener.get(); } | 147 AudioListener* listener() { return m_listener; } |
148 | 148 |
149 virtual bool hasRealtimeConstraint() = 0; | 149 virtual bool hasRealtimeConstraint() = 0; |
150 | 150 |
151 // The AudioNode create methods are called on the main thread (from JavaScri
pt). | 151 // The AudioNode create methods are called on the main thread (from JavaScri
pt). |
152 AudioBufferSourceNode* createBufferSource(ExceptionState&); | 152 AudioBufferSourceNode* createBufferSource(ExceptionState&); |
153 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); | 153 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc
eptionState&); |
154 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); | 154 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS
tate&); |
155 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); | 155 MediaStreamAudioDestinationNode* createMediaStreamDestination(ExceptionState
&); |
156 GainNode* createGain(ExceptionState&); | 156 GainNode* createGain(ExceptionState&); |
157 BiquadFilterNode* createBiquadFilter(ExceptionState&); | 157 BiquadFilterNode* createBiquadFilter(ExceptionState&); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 private: | 292 private: |
293 bool m_isCleared; | 293 bool m_isCleared; |
294 void clear(); | 294 void clear(); |
295 | 295 |
296 void throwExceptionForClosedState(ExceptionState&); | 296 void throwExceptionForClosedState(ExceptionState&); |
297 | 297 |
298 // When the context goes away, there might still be some sources which | 298 // When the context goes away, there might still be some sources which |
299 // haven't finished playing. Make sure to release them here. | 299 // haven't finished playing. Make sure to release them here. |
300 void releaseActiveSourceNodes(); | 300 void releaseActiveSourceNodes(); |
301 | 301 |
| 302 void removeFinishedSourceNodes(); |
| 303 |
302 Member<AudioListener> m_listener; | 304 Member<AudioListener> m_listener; |
303 | 305 |
304 // Only accessed in the audio thread. | 306 // Only accessed in the audio thread. |
305 // These raw pointers are safe because AudioSourceNodes in | 307 // These raw pointers are safe because AudioSourceNodes in |
306 // m_activeSourceNodes own them. | 308 // m_activeSourceNodes own them. |
307 Vector<AudioHandler*> m_finishedSourceHandlers; | 309 Vector<AudioHandler*> m_finishedSourceHandlers; |
308 | 310 |
309 // List of source nodes. This is either accessed when the graph lock is | 311 // List of source nodes. This is either accessed when the graph lock is |
310 // held, or on the main thread when the audio thread has finished. | 312 // held, or on the main thread when the audio thread has finished. |
311 // Oilpan: This Vector holds connection references. We must call | 313 // Oilpan: This Vector holds connection references. We must call |
312 // AudioHandler::makeConnection when we add an AudioNode to this, and must | 314 // AudioHandler::makeConnection when we add an AudioNode to this, and must |
313 // call AudioHandler::breakConnection() when we remove an AudioNode from | 315 // call AudioHandler::breakConnection() when we remove an AudioNode from |
314 // this. | 316 // this. |
315 HeapVector<Member<AudioNode>> m_activeSourceNodes; | 317 HeapVector<Member<AudioNode>> m_activeSourceNodes; |
316 | 318 |
| 319 // The main thread controls m_activeSourceNodes, all updates and additions |
| 320 // are performed by it. When the audio thread marks a source node as finishe
d, |
| 321 // the nodes are added to |m_finishedSourceNodes| and scheduled for removal |
| 322 // from |m_activeSourceNodes| by the main thread. |
| 323 Vector<UntracedMember<AudioNode>> m_finishedSourceNodes; |
| 324 |
317 // FIXME(dominicc): Move these to AudioContext because only | 325 // FIXME(dominicc): Move these to AudioContext because only |
318 // it creates these Promises. | 326 // it creates these Promises. |
319 // Handle Promises for resume() and suspend() | 327 // Handle Promises for resume() and suspend() |
320 void resolvePromisesForResume(); | 328 void resolvePromisesForResume(); |
321 void resolvePromisesForResumeOnMainThread(); | 329 void resolvePromisesForResumeOnMainThread(); |
322 | 330 |
323 // When the context is going away, reject any pending script promise resolve
rs. | 331 // When the context is going away, reject any pending script promise resolve
rs. |
324 virtual void rejectPendingResolvers(); | 332 virtual void rejectPendingResolvers(); |
325 | 333 |
326 // True if we're in the process of resolving promises for resume(). Resolvi
ng can take some | 334 // True if we're in the process of resolving promises for resume(). Resolvi
ng can take some |
327 // time and the audio context process loop is very fast, so we don't want to
call resolve an | 335 // time and the audio context process loop is very fast, so we don't want to
call resolve an |
328 // excessive number of times. | 336 // excessive number of times. |
329 bool m_isResolvingResumePromises; | 337 bool m_isResolvingResumePromises; |
330 | 338 |
331 unsigned m_connectionCount; | 339 unsigned m_connectionCount; |
332 | 340 |
333 // Graph locking. | 341 // Graph locking. |
334 bool m_didInitializeContextGraphMutex; | |
335 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; | 342 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; |
336 | 343 |
337 // The state of the AbstractAudioContext. | 344 // The state of the AbstractAudioContext. |
338 AudioContextState m_contextState; | 345 AudioContextState m_contextState; |
339 | 346 |
340 AsyncAudioDecoder m_audioDecoder; | 347 AsyncAudioDecoder m_audioDecoder; |
341 | 348 |
342 // When a context is closed, the sample rate is cleared. But decodeAudioDat
a can be called | 349 // When a context is closed, the sample rate is cleared. But decodeAudioDat
a can be called |
343 // after the context has been closed and it needs the sample rate. When the
context is closed, | 350 // after the context has been closed and it needs the sample rate. When the
context is closed, |
344 // the sample rate is saved here. | 351 // the sample rate is saved here. |
(...skipping 12 matching lines...) Expand all Loading... |
357 Member<PeriodicWave> m_periodicWaveTriangle; | 364 Member<PeriodicWave> m_periodicWaveTriangle; |
358 | 365 |
359 // This is considering 32 is large enough for multiple channels audio. | 366 // This is considering 32 is large enough for multiple channels audio. |
360 // It is somewhat arbitrary and could be increased if necessary. | 367 // It is somewhat arbitrary and could be increased if necessary. |
361 enum { MaxNumberOfChannels = 32 }; | 368 enum { MaxNumberOfChannels = 32 }; |
362 }; | 369 }; |
363 | 370 |
364 } // namespace blink | 371 } // namespace blink |
365 | 372 |
366 #endif // AbstractAudioContext_h | 373 #endif // AbstractAudioContext_h |
OLD | NEW |