| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 , m_isInitialized(false) | 112 , m_isInitialized(false) |
| 113 , m_isAudioThreadFinished(false) | 113 , m_isAudioThreadFinished(false) |
| 114 , m_destinationNode(nullptr) | 114 , m_destinationNode(nullptr) |
| 115 , m_isDeletionScheduled(false) | 115 , m_isDeletionScheduled(false) |
| 116 , m_automaticPullNodesNeedUpdating(false) | 116 , m_automaticPullNodesNeedUpdating(false) |
| 117 , m_connectionCount(0) | 117 , m_connectionCount(0) |
| 118 , m_audioThread(0) | 118 , m_audioThread(0) |
| 119 , m_graphOwnerThread(UndefinedThreadIdentifier) | 119 , m_graphOwnerThread(UndefinedThreadIdentifier) |
| 120 , m_isOfflineContext(false) | 120 , m_isOfflineContext(false) |
| 121 { | 121 { |
| 122 m_destinationNode = DefaultAudioDestinationNode::create(this); |
| 123 |
| 122 constructCommon(); | 124 constructCommon(); |
| 123 | |
| 124 m_destinationNode = DefaultAudioDestinationNode::create(this); | |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Constructor for offline (non-realtime) rendering. | 127 // Constructor for offline (non-realtime) rendering. |
| 128 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
numberOfFrames, float sampleRate) | 128 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
numberOfFrames, float sampleRate) |
| 129 : ActiveDOMObject(document) | 129 : ActiveDOMObject(document) |
| 130 , m_isStopScheduled(false) | 130 , m_isStopScheduled(false) |
| 131 , m_isCleared(false) | 131 , m_isCleared(false) |
| 132 , m_isInitialized(false) | 132 , m_isInitialized(false) |
| 133 , m_isAudioThreadFinished(false) | 133 , m_isAudioThreadFinished(false) |
| 134 , m_destinationNode(nullptr) | 134 , m_destinationNode(nullptr) |
| 135 , m_automaticPullNodesNeedUpdating(false) | 135 , m_automaticPullNodesNeedUpdating(false) |
| 136 , m_connectionCount(0) | 136 , m_connectionCount(0) |
| 137 , m_audioThread(0) | 137 , m_audioThread(0) |
| 138 , m_graphOwnerThread(UndefinedThreadIdentifier) | 138 , m_graphOwnerThread(UndefinedThreadIdentifier) |
| 139 , m_isOfflineContext(true) | 139 , m_isOfflineContext(true) |
| 140 { | 140 { |
| 141 constructCommon(); | |
| 142 | |
| 143 // Create a new destination for offline rendering. | 141 // Create a new destination for offline rendering. |
| 144 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl
eRate); | 142 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl
eRate); |
| 145 if (m_renderTarget.get()) | 143 if (m_renderTarget.get()) |
| 146 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa
rget.get()); | 144 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa
rget.get()); |
| 145 |
| 146 constructCommon(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void AudioContext::constructCommon() | 149 void AudioContext::constructCommon() |
| 150 { | 150 { |
| 151 ScriptWrappable::init(this); | 151 ScriptWrappable::init(this); |
| 152 | 152 |
| 153 FFTFrame::initialize(); | 153 FFTFrame::initialize(); |
| 154 | 154 |
| 155 m_listener = AudioListener::create(); | 155 m_listener = AudioListener::create(); |
| 156 |
| 157 initialize(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 AudioContext::~AudioContext() | 160 AudioContext::~AudioContext() |
| 159 { | 161 { |
| 160 #if DEBUG_AUDIONODE_REFERENCES | 162 #if DEBUG_AUDIONODE_REFERENCES |
| 161 fprintf(stderr, "%p: AudioContext::~AudioContext()\n", this); | 163 fprintf(stderr, "%p: AudioContext::~AudioContext()\n", this); |
| 162 #endif | 164 #endif |
| 163 // AudioNodes keep a reference to their context, so there should be no way t
o be in the destructor if there are still AudioNodes around. | 165 // AudioNodes keep a reference to their context, so there should be no way t
o be in the destructor if there are still AudioNodes around. |
| 164 ASSERT(!m_isInitialized); | 166 ASSERT(!m_isInitialized); |
| 165 ASSERT(!m_nodesToDelete.size()); | 167 ASSERT(!m_nodesToDelete.size()); |
| 166 ASSERT(!m_referencedNodes.size()); | 168 ASSERT(!m_referencedNodes.size()); |
| 167 ASSERT(!m_finishedNodes.size()); | 169 ASSERT(!m_finishedNodes.size()); |
| 168 ASSERT(!m_automaticPullNodes.size()); | 170 ASSERT(!m_automaticPullNodes.size()); |
| 169 if (m_automaticPullNodesNeedUpdating) | 171 if (m_automaticPullNodesNeedUpdating) |
| 170 m_renderingAutomaticPullNodes.resize(m_automaticPullNodes.size()); | 172 m_renderingAutomaticPullNodes.resize(m_automaticPullNodes.size()); |
| 171 ASSERT(!m_renderingAutomaticPullNodes.size()); | 173 ASSERT(!m_renderingAutomaticPullNodes.size()); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void AudioContext::lazyInitialize() | 176 void AudioContext::initialize() |
| 175 { | 177 { |
| 176 if (!m_isInitialized) { | 178 if (!m_isInitialized) { |
| 177 // Don't allow the context to initialize a second time after it's alread
y been explicitly uninitialized. | 179 // Don't allow the context to initialize a second time after it's alread
y been explicitly uninitialized. |
| 178 ASSERT(!m_isAudioThreadFinished); | 180 ASSERT(!m_isAudioThreadFinished); |
| 179 if (!m_isAudioThreadFinished) { | 181 if (!m_isAudioThreadFinished) { |
| 180 // Creation of a destination node should not start the audio HW. The | 182 // Creation of a destination node should not start the audio HW. The |
| 181 // creation of any other AudioNode will initialize the audio HW and
start processing | 183 // creation of any other AudioNode will initialize the audio HW and
start processing |
| 182 if (m_destinationNode.get()) { | 184 if (m_destinationNode.get()) { |
| 183 m_destinationNode->initialize(); | 185 m_destinationNode->initialize(); |
| 184 | 186 |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 { | 973 { |
| 972 visitor->trace(m_renderTarget); | 974 visitor->trace(m_renderTarget); |
| 973 visitor->trace(m_destinationNode); | 975 visitor->trace(m_destinationNode); |
| 974 visitor->trace(m_listener); | 976 visitor->trace(m_listener); |
| 975 visitor->trace(m_dirtySummingJunctions); | 977 visitor->trace(m_dirtySummingJunctions); |
| 976 } | 978 } |
| 977 | 979 |
| 978 } // namespace WebCore | 980 } // namespace WebCore |
| 979 | 981 |
| 980 #endif // ENABLE(WEB_AUDIO) | 982 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |