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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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&, ExceptionState&); | 80 static PassRefPtr<AudioContext> create(Document&, ExceptionState&); |
81 | 81 |
82 // Deprecated: create an AudioContext for offline (non-realtime) rendering. | 82 // Deprecated: create an AudioContext for offline (non-realtime) rendering. |
83 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&); |
84 | 84 |
85 virtual ~AudioContext(); | 85 virtual ~AudioContext(); |
86 | 86 |
87 bool isInitialized() const; | 87 bool isInitialized() const; |
| 88 // The constructor of an AudioNode must call this to initialize the context. |
| 89 void lazyInitialize(); |
88 | 90 |
89 bool isOfflineContext() { return m_isOfflineContext; } | 91 bool isOfflineContext() { return m_isOfflineContext; } |
90 | 92 |
91 // Document notification | 93 // Document notification |
92 virtual void stop() OVERRIDE FINAL; | 94 virtual void stop() OVERRIDE FINAL; |
93 virtual bool hasPendingActivity() const OVERRIDE; | 95 virtual bool hasPendingActivity() const OVERRIDE; |
94 | 96 |
95 AudioDestinationNode* destination() { return m_destinationNode.get(); } | 97 AudioDestinationNode* destination() { return m_destinationNode.get(); } |
96 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF
rame(); } | 98 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF
rame(); } |
97 double currentTime() const { return m_destinationNode->currentTime(); } | 99 double currentTime() const { return m_destinationNode->currentTime(); } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 240 |
239 protected: | 241 protected: |
240 explicit AudioContext(Document*); | 242 explicit AudioContext(Document*); |
241 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); | 243 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl
oat sampleRate); |
242 | 244 |
243 static bool isSampleRateRangeGood(float sampleRate); | 245 static bool isSampleRateRangeGood(float sampleRate); |
244 | 246 |
245 private: | 247 private: |
246 void constructCommon(); | 248 void constructCommon(); |
247 | 249 |
248 void lazyInitialize(); | |
249 void uninitialize(); | 250 void uninitialize(); |
250 | 251 |
251 // ExecutionContext calls stop twice. | 252 // ExecutionContext calls stop twice. |
252 // We'd like to schedule only one stop action for them. | 253 // We'd like to schedule only one stop action for them. |
253 bool m_isStopScheduled; | 254 bool m_isStopScheduled; |
254 static void stopDispatch(void* userData); | 255 static void stopDispatch(void* userData); |
255 bool m_isCleared; | 256 bool m_isCleared; |
256 void clear(); | 257 void clear(); |
257 | 258 |
258 void scheduleNodeDeletion(); | 259 void scheduleNodeDeletion(); |
259 static void deleteMarkedNodesDispatch(void* userData); | 260 static void deleteMarkedNodesDispatch(void* userData); |
260 | 261 |
| 262 // Set to true when the destination node has been initialized and is ready t
o process data. |
261 bool m_isInitialized; | 263 bool m_isInitialized; |
262 bool m_isAudioThreadFinished; | 264 bool m_isAudioThreadFinished; |
263 | 265 |
264 // The context itself keeps a reference to all source nodes. The source nod
es, then reference all nodes they're connected to. | 266 // The context itself keeps a reference to all source nodes. The source nod
es, then reference all nodes they're connected to. |
265 // In turn, these nodes reference all nodes they're connected to. All nodes
are ultimately connected to the AudioDestinationNode. | 267 // In turn, these nodes reference all nodes they're connected to. All nodes
are ultimately connected to the AudioDestinationNode. |
266 // When the context dereferences a source node, it will be deactivated from
the rendering graph along with all other nodes it is | 268 // When the context dereferences a source node, it will be deactivated from
the rendering graph along with all other nodes it is |
267 // uniquely connected to. See the AudioNode::ref() and AudioNode::deref() m
ethods for more details. | 269 // uniquely connected to. See the AudioNode::ref() and AudioNode::deref() m
ethods for more details. |
268 void refNode(AudioNode*); | 270 void refNode(AudioNode*); |
269 void derefNode(AudioNode*); | 271 void derefNode(AudioNode*); |
270 | 272 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // It is somewhat arbitrary and could be increased if necessary. | 329 // It is somewhat arbitrary and could be increased if necessary. |
328 enum { MaxNumberOfChannels = 32 }; | 330 enum { MaxNumberOfChannels = 32 }; |
329 | 331 |
330 // Number of AudioBufferSourceNodes that are active (playing). | 332 // Number of AudioBufferSourceNodes that are active (playing). |
331 int m_activeSourceCount; | 333 int m_activeSourceCount; |
332 }; | 334 }; |
333 | 335 |
334 } // WebCore | 336 } // WebCore |
335 | 337 |
336 #endif // AudioContext_h | 338 #endif // AudioContext_h |
OLD | NEW |