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 27 matching lines...) Expand all Loading... |
38 #include <wtf/MainThread.h> | 38 #include <wtf/MainThread.h> |
39 #include <wtf/MemoryInstrumentationVector.h> | 39 #include <wtf/MemoryInstrumentationVector.h> |
40 | 40 |
41 #if DEBUG_AUDIONODE_REFERENCES | 41 #if DEBUG_AUDIONODE_REFERENCES |
42 #include <stdio.h> | 42 #include <stdio.h> |
43 #endif | 43 #endif |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 AudioNode::AudioNode(AudioContext* context, float sampleRate) | 47 AudioNode::AudioNode(AudioContext* context, float sampleRate) |
48 : m_isInitialized(false) | 48 : ActiveDOMObject(context->scriptExecutionContext()) |
| 49 , m_isInitialized(false) |
49 , m_nodeType(NodeTypeUnknown) | 50 , m_nodeType(NodeTypeUnknown) |
50 , m_context(context) | 51 , m_context(context) |
51 , m_sampleRate(sampleRate) | 52 , m_sampleRate(sampleRate) |
52 , m_lastProcessingTime(-1) | 53 , m_lastProcessingTime(-1) |
53 , m_lastNonSilentTime(-1) | 54 , m_lastNonSilentTime(-1) |
54 , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefC
ounted class) | 55 , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefC
ounted class) |
55 , m_connectionRefCount(0) | 56 , m_connectionRefCount(0) |
56 , m_isMarkedForDeletion(false) | 57 , m_isMarkedForDeletion(false) |
57 , m_isDisabled(false) | 58 , m_isDisabled(false) |
58 , m_channelCount(2) | 59 , m_channelCount(2) |
59 , m_channelCountMode(Max) | 60 , m_channelCountMode(Max) |
60 , m_channelInterpretation(AudioBus::Speakers) | 61 , m_channelInterpretation(AudioBus::Speakers) |
61 { | 62 { |
62 #if DEBUG_AUDIONODE_REFERENCES | 63 #if DEBUG_AUDIONODE_REFERENCES |
63 if (!s_isNodeCountInitialized) { | 64 if (!s_isNodeCountInitialized) { |
64 s_isNodeCountInitialized = true; | 65 s_isNodeCountInitialized = true; |
65 atexit(AudioNode::printNodeCounts); | 66 atexit(AudioNode::printNodeCounts); |
66 } | 67 } |
67 #endif | 68 #endif |
| 69 |
| 70 // since we're just using the ActiveDOMObject instance for GC, |
| 71 // we can suspendIfNeeded here. suspendIfNeeded needs to be called |
| 72 // at some point on every ActiveDOMObject. |
| 73 suspendIfNeeded(); |
68 } | 74 } |
69 | 75 |
70 AudioNode::~AudioNode() | 76 AudioNode::~AudioNode() |
71 { | 77 { |
72 #if DEBUG_AUDIONODE_REFERENCES | 78 #if DEBUG_AUDIONODE_REFERENCES |
73 --s_nodeCount[nodeType()]; | 79 --s_nodeCount[nodeType()]; |
74 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d %d\n", this, nodeType(),
m_normalRefCount, m_connectionRefCount); | 80 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d %d\n", this, nodeType(),
m_normalRefCount, m_connectionRefCount); |
75 #endif | 81 #endif |
76 } | 82 } |
77 | 83 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 else | 281 else |
276 ec = INVALID_STATE_ERR; | 282 ec = INVALID_STATE_ERR; |
277 } | 283 } |
278 | 284 |
279 void AudioNode::updateChannelsForInputs() | 285 void AudioNode::updateChannelsForInputs() |
280 { | 286 { |
281 for (unsigned i = 0; i < m_inputs.size(); ++i) | 287 for (unsigned i = 0; i < m_inputs.size(); ++i) |
282 input(i)->changedOutputs(); | 288 input(i)->changedOutputs(); |
283 } | 289 } |
284 | 290 |
| 291 const AtomicString& AudioNode::interfaceName() const |
| 292 { |
| 293 return eventNames().interfaceForAudioNode; |
| 294 } |
| 295 |
| 296 ScriptExecutionContext* AudioNode::scriptExecutionContext() const |
| 297 { |
| 298 return const_cast<AudioNode*>(this)->context()->scriptExecutionContext(); |
| 299 } |
| 300 |
| 301 |
| 302 bool AudioNode::hasPendingActivity() const |
| 303 { |
| 304 return !m_isDisabled && (m_connectionRefCount > 0); |
| 305 } |
| 306 |
285 void AudioNode::processIfNecessary(size_t framesToProcess) | 307 void AudioNode::processIfNecessary(size_t framesToProcess) |
286 { | 308 { |
287 ASSERT(context()->isAudioThread()); | 309 ASSERT(context()->isAudioThread()); |
288 | 310 |
289 if (!isInitialized()) | 311 if (!isInitialized()) |
290 return; | 312 return; |
291 | 313 |
292 // Ensure that we only process once per rendering quantum. | 314 // Ensure that we only process once per rendering quantum. |
293 // This handles the "fanout" problem where an output is connected to multipl
e inputs. | 315 // This handles the "fanout" problem where an output is connected to multipl
e inputs. |
294 // The first time we're called during this time slice we process, but after
that we don't want to re-process, | 316 // The first time we're called during this time slice we process, but after
that we don't want to re-process, |
295 // instead our output(s) will already have the results cached in their bus; | 317 // instead our output(s) will already have the results cached in their bus; |
296 double currentTime = context()->currentTime(); | 318 double currentTime = context()->currentTime(); |
297 if (m_lastProcessingTime != currentTime) { | 319 if (m_lastProcessingTime != currentTime) { |
298 m_lastProcessingTime = currentTime; // important to first update this ti
me because of feedback loops in the rendering graph | 320 m_lastProcessingTime = currentTime; // important to first update this ti
me because of feedback loops in the rendering graph |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); | 538 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); |
517 | 539 |
518 fprintf(stderr, "===========================\n\n\n"); | 540 fprintf(stderr, "===========================\n\n\n"); |
519 } | 541 } |
520 | 542 |
521 #endif // DEBUG_AUDIONODE_REFERENCES | 543 #endif // DEBUG_AUDIONODE_REFERENCES |
522 | 544 |
523 } // namespace WebCore | 545 } // namespace WebCore |
524 | 546 |
525 #endif // ENABLE(WEB_AUDIO) | 547 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |