OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 , m_renderThread(0) | 46 , m_renderThread(0) |
47 , m_startedRendering(false) | 47 , m_startedRendering(false) |
48 { | 48 { |
49 m_renderBus = adoptPtr(new AudioBus(renderTarget->numberOfChannels(), render
QuantumSize)); | 49 m_renderBus = adoptPtr(new AudioBus(renderTarget->numberOfChannels(), render
QuantumSize)); |
50 | 50 |
51 initialize(); | 51 initialize(); |
52 } | 52 } |
53 | 53 |
54 OfflineAudioDestinationNode::~OfflineAudioDestinationNode() | 54 OfflineAudioDestinationNode::~OfflineAudioDestinationNode() |
55 { | 55 { |
56 if (m_renderThread) | |
57 waitForThreadCompletion(m_renderThread, 0); | |
58 | |
59 uninitialize(); | 56 uninitialize(); |
60 } | 57 } |
61 | 58 |
62 void OfflineAudioDestinationNode::initialize() | 59 void OfflineAudioDestinationNode::initialize() |
63 { | 60 { |
64 if (isInitialized()) | 61 if (isInitialized()) |
65 return; | 62 return; |
66 | 63 |
67 AudioNode::initialize(); | 64 AudioNode::initialize(); |
68 } | 65 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 float* source = m_renderBus->channel(channelIndex)->data(); | 138 float* source = m_renderBus->channel(channelIndex)->data(); |
142 float* destination = m_renderTarget->getChannelData(channelIndex)->d
ata(); | 139 float* destination = m_renderTarget->getChannelData(channelIndex)->d
ata(); |
143 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop
y); | 140 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop
y); |
144 } | 141 } |
145 | 142 |
146 n += framesAvailableToCopy; | 143 n += framesAvailableToCopy; |
147 framesToProcess -= framesAvailableToCopy; | 144 framesToProcess -= framesAvailableToCopy; |
148 } | 145 } |
149 | 146 |
150 // Our work is done. Let the AudioContext know. | 147 // Our work is done. Let the AudioContext know. |
151 // See corresponding deref() call in notifyCompleteDispatch(). | |
152 ref(); | |
153 callOnMainThread(notifyCompleteDispatch, this); | 148 callOnMainThread(notifyCompleteDispatch, this); |
154 } | 149 } |
155 | 150 |
156 void OfflineAudioDestinationNode::notifyCompleteDispatch(void* userData) | 151 void OfflineAudioDestinationNode::notifyCompleteDispatch(void* userData) |
157 { | 152 { |
158 OfflineAudioDestinationNode* destinationNode = static_cast<OfflineAudioDesti
nationNode*>(userData); | 153 OfflineAudioDestinationNode* destinationNode = static_cast<OfflineAudioDesti
nationNode*>(userData); |
159 ASSERT(destinationNode); | 154 ASSERT(destinationNode); |
160 if (!destinationNode) | 155 if (!destinationNode) |
161 return; | 156 return; |
162 | 157 |
163 destinationNode->notifyComplete(); | 158 destinationNode->notifyComplete(); |
164 destinationNode->deref(); | 159 destinationNode->deref(); |
165 } | 160 } |
166 | 161 |
167 void OfflineAudioDestinationNode::notifyComplete() | 162 void OfflineAudioDestinationNode::notifyComplete() |
168 { | 163 { |
169 context()->fireCompletionEvent(); | 164 context()->fireCompletionEvent(); |
170 } | 165 } |
171 | 166 |
172 } // namespace WebCore | 167 } // namespace WebCore |
173 | 168 |
174 #endif // ENABLE(WEB_AUDIO) | 169 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |