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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class MediaStreamAudioSourceNode; | 67 class MediaStreamAudioSourceNode; |
68 class OscillatorNode; | 68 class OscillatorNode; |
69 class PannerNode; | 69 class PannerNode; |
70 class PeriodicWave; | 70 class PeriodicWave; |
71 class ScriptProcessorNode; | 71 class ScriptProcessorNode; |
72 class WaveShaperNode; | 72 class WaveShaperNode; |
73 | 73 |
74 // AudioContext is the cornerstone of the web audio API and all AudioNodes are c
reated from it. | 74 // AudioContext is the cornerstone of the web audio API and all AudioNodes are c
reated from it. |
75 // For thread safety between the audio thread and the main thread, it has a rend
ering graph locking mechanism. | 75 // For thread safety between the audio thread and the main thread, it has a rend
ering graph locking mechanism. |
76 | 76 |
77 class AudioContext : public ActiveDOMObject, public ScriptWrappable, public Thre
adSafeRefCounted<AudioContext>, public EventTarget { | 77 class AudioContext : public ActiveDOMObject, public ScriptWrappable, public Thre
adSafeRefCounted<AudioContext>, public EventTargetWithInlineData { |
78 public: | 78 public: |
79 // Create an AudioContext for rendering to the audio hardware. | 79 // Create an AudioContext for rendering to the audio hardware. |
80 static PassRefPtr<AudioContext> create(Document*); | 80 static PassRefPtr<AudioContext> create(Document*); |
81 | 81 |
82 // Create an AudioContext for offline (non-realtime) rendering. | 82 // Create an AudioContext for offline (non-realtime) rendering. |
83 static PassRefPtr<AudioContext> createOfflineContext(Document*, unsigned num
berOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&); | 83 static PassRefPtr<AudioContext> createOfflineContext(Document*, unsigned num
berOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&); |
84 | 84 |
85 virtual ~AudioContext(); | 85 virtual ~AudioContext(); |
86 | 86 |
87 bool isInitialized() const; | 87 bool isInitialized() const; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void handleDeferredFinishDerefs(); | 226 void handleDeferredFinishDerefs(); |
227 | 227 |
228 // Only accessed when the graph lock is held. | 228 // Only accessed when the graph lock is held. |
229 void markSummingJunctionDirty(AudioSummingJunction*); | 229 void markSummingJunctionDirty(AudioSummingJunction*); |
230 void markAudioNodeOutputDirty(AudioNodeOutput*); | 230 void markAudioNodeOutputDirty(AudioNodeOutput*); |
231 | 231 |
232 // Must be called on main thread. | 232 // Must be called on main thread. |
233 void removeMarkedSummingJunction(AudioSummingJunction*); | 233 void removeMarkedSummingJunction(AudioSummingJunction*); |
234 | 234 |
235 // EventTarget | 235 // EventTarget |
236 virtual const AtomicString& interfaceName() const; | 236 virtual const AtomicString& interfaceName() const OVERRIDE; |
237 virtual ScriptExecutionContext* scriptExecutionContext() const; | 237 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
238 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } | |
239 virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData
; } | |
240 | 238 |
241 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); | 239 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); |
242 | 240 |
243 // Reconcile ref/deref which are defined both in ThreadSafeRefCounted and Ev
entTarget. | 241 // Reconcile ref/deref which are defined both in ThreadSafeRefCounted and Ev
entTarget. |
244 using ThreadSafeRefCounted<AudioContext>::ref; | 242 using ThreadSafeRefCounted<AudioContext>::ref; |
245 using ThreadSafeRefCounted<AudioContext>::deref; | 243 using ThreadSafeRefCounted<AudioContext>::deref; |
246 | 244 |
247 void startRendering(); | 245 void startRendering(); |
248 void fireCompletionEvent(); | 246 void fireCompletionEvent(); |
249 | 247 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 volatile ThreadIdentifier m_audioThread; | 324 volatile ThreadIdentifier m_audioThread; |
327 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th
is is the thread which owns it, otherwise == UndefinedThreadIdentifier | 325 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th
is is the thread which owns it, otherwise == UndefinedThreadIdentifier |
328 | 326 |
329 // Only accessed in the audio thread. | 327 // Only accessed in the audio thread. |
330 Vector<AudioNode*> m_deferredFinishDerefList; | 328 Vector<AudioNode*> m_deferredFinishDerefList; |
331 | 329 |
332 // HRTF Database loader | 330 // HRTF Database loader |
333 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader; | 331 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader; |
334 | 332 |
335 // EventTarget | 333 // EventTarget |
336 virtual void refEventTarget() { ref(); } | 334 virtual void refEventTarget() OVERRIDE { ref(); } |
337 virtual void derefEventTarget() { deref(); } | 335 virtual void derefEventTarget() OVERRIDE { deref(); } |
338 EventTargetData m_eventTargetData; | |
339 | 336 |
340 RefPtr<AudioBuffer> m_renderTarget; | 337 RefPtr<AudioBuffer> m_renderTarget; |
341 | 338 |
342 bool m_isOfflineContext; | 339 bool m_isOfflineContext; |
343 | 340 |
344 AsyncAudioDecoder m_audioDecoder; | 341 AsyncAudioDecoder m_audioDecoder; |
345 | 342 |
346 // This is considering 32 is large enough for multiple channels audio. | 343 // This is considering 32 is large enough for multiple channels audio. |
347 // It is somewhat arbitrary and could be increased if necessary. | 344 // It is somewhat arbitrary and could be increased if necessary. |
348 enum { MaxNumberOfChannels = 32 }; | 345 enum { MaxNumberOfChannels = 32 }; |
349 | 346 |
350 // Number of AudioBufferSourceNodes that are active (playing). | 347 // Number of AudioBufferSourceNodes that are active (playing). |
351 int m_activeSourceCount; | 348 int m_activeSourceCount; |
352 }; | 349 }; |
353 | 350 |
354 } // WebCore | 351 } // WebCore |
355 | 352 |
356 #endif // AudioContext_h | 353 #endif // AudioContext_h |
OLD | NEW |