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 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #ifndef AudioContext_h | 25 #ifndef AudioContext_h |
26 #define AudioContext_h | 26 #define AudioContext_h |
27 | 27 |
28 #include "bindings/v8/ScriptWrappable.h" | 28 #include "bindings/v8/ScriptWrappable.h" |
29 #include "core/dom/ActiveDOMObject.h" | 29 #include "core/dom/ActiveDOMObject.h" |
30 #include "core/events/EventListener.h" | 30 #include "core/events/EventListener.h" |
31 #include "core/events/EventTarget.h" | 31 #include "core/events/EventTarget.h" |
32 #include "platform/audio/AudioBus.h" | 32 #include "platform/audio/AudioBus.h" |
33 #include "platform/audio/HRTFDatabaseLoader.h" | |
34 #include "modules/webaudio/AsyncAudioDecoder.h" | 33 #include "modules/webaudio/AsyncAudioDecoder.h" |
35 #include "modules/webaudio/AudioDestinationNode.h" | 34 #include "modules/webaudio/AudioDestinationNode.h" |
36 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
37 #include "wtf/MainThread.h" | 36 #include "wtf/MainThread.h" |
38 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
39 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
40 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
41 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
42 #include "wtf/ThreadSafeRefCounted.h" | 41 #include "wtf/ThreadSafeRefCounted.h" |
43 #include "wtf/Threading.h" | 42 #include "wtf/Threading.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 81 |
83 // Deprecated: create an AudioContext for offline (non-realtime) rendering. | 82 // Deprecated: create an AudioContext for offline (non-realtime) rendering. |
84 static PassRefPtr<AudioContext> create(Document&, unsigned numberOfChannels,
size_t numberOfFrames, float sampleRate, ExceptionState&); | 83 static PassRefPtr<AudioContext> create(Document&, unsigned numberOfChannels,
size_t numberOfFrames, float sampleRate, ExceptionState&); |
85 | 84 |
86 virtual ~AudioContext(); | 85 virtual ~AudioContext(); |
87 | 86 |
88 bool isInitialized() const; | 87 bool isInitialized() const; |
89 | 88 |
90 bool isOfflineContext() { return m_isOfflineContext; } | 89 bool isOfflineContext() { return m_isOfflineContext; } |
91 | 90 |
92 // Returns true when initialize() was called AND all asynchronous initializa
tion has completed. | |
93 bool isRunnable() const; | |
94 | |
95 HRTFDatabaseLoader* hrtfDatabaseLoader() const { return m_hrtfDatabaseLoader
.get(); } | |
96 | |
97 // Document notification | 91 // Document notification |
98 virtual void stop() OVERRIDE FINAL; | 92 virtual void stop() OVERRIDE FINAL; |
99 | 93 |
100 AudioDestinationNode* destination() { return m_destinationNode.get(); } | 94 AudioDestinationNode* destination() { return m_destinationNode.get(); } |
101 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF
rame(); } | 95 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF
rame(); } |
102 double currentTime() const { return m_destinationNode->currentTime(); } | 96 double currentTime() const { return m_destinationNode->currentTime(); } |
103 float sampleRate() const { return m_destinationNode->sampleRate(); } | 97 float sampleRate() const { return m_destinationNode->sampleRate(); } |
104 unsigned long activeSourceCount() const { return static_cast<unsigned long>(
m_activeSourceCount); } | 98 unsigned long activeSourceCount() const { return static_cast<unsigned long>(
m_activeSourceCount); } |
105 | 99 |
106 void incrementActiveSourceCount(); | 100 void incrementActiveSourceCount(); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 unsigned m_connectionCount; | 308 unsigned m_connectionCount; |
315 | 309 |
316 // Graph locking. | 310 // Graph locking. |
317 Mutex m_contextGraphMutex; | 311 Mutex m_contextGraphMutex; |
318 volatile ThreadIdentifier m_audioThread; | 312 volatile ThreadIdentifier m_audioThread; |
319 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th
is is the thread which owns it, otherwise == UndefinedThreadIdentifier | 313 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th
is is the thread which owns it, otherwise == UndefinedThreadIdentifier |
320 | 314 |
321 // Only accessed in the audio thread. | 315 // Only accessed in the audio thread. |
322 Vector<AudioNode*> m_deferredFinishDerefList; | 316 Vector<AudioNode*> m_deferredFinishDerefList; |
323 | 317 |
324 // HRTF Database loader | |
325 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader; | |
326 | |
327 RefPtr<AudioBuffer> m_renderTarget; | 318 RefPtr<AudioBuffer> m_renderTarget; |
328 | 319 |
329 bool m_isOfflineContext; | 320 bool m_isOfflineContext; |
330 | 321 |
331 AsyncAudioDecoder m_audioDecoder; | 322 AsyncAudioDecoder m_audioDecoder; |
332 | 323 |
333 // This is considering 32 is large enough for multiple channels audio. | 324 // This is considering 32 is large enough for multiple channels audio. |
334 // It is somewhat arbitrary and could be increased if necessary. | 325 // It is somewhat arbitrary and could be increased if necessary. |
335 enum { MaxNumberOfChannels = 32 }; | 326 enum { MaxNumberOfChannels = 32 }; |
336 | 327 |
337 // Number of AudioBufferSourceNodes that are active (playing). | 328 // Number of AudioBufferSourceNodes that are active (playing). |
338 int m_activeSourceCount; | 329 int m_activeSourceCount; |
339 }; | 330 }; |
340 | 331 |
341 } // WebCore | 332 } // WebCore |
342 | 333 |
343 #endif // AudioContext_h | 334 #endif // AudioContext_h |
OLD | NEW |