Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/WebCore/webaudio/OfflineAudioDestinationNode.cpp

Issue 8037053: Merge 94984 - Address lifetime issues in OfflineAudioDestinationNode (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
56 uninitialize(); 59 uninitialize();
57 } 60 }
58 61
59 void OfflineAudioDestinationNode::initialize() 62 void OfflineAudioDestinationNode::initialize()
60 { 63 {
61 if (isInitialized()) 64 if (isInitialized())
62 return; 65 return;
63 66
64 AudioNode::initialize(); 67 AudioNode::initialize();
65 } 68 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 float* source = m_renderBus->channel(channelIndex)->data(); 141 float* source = m_renderBus->channel(channelIndex)->data();
139 float* destination = m_renderTarget->getChannelData(channelIndex)->d ata(); 142 float* destination = m_renderTarget->getChannelData(channelIndex)->d ata();
140 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop y); 143 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop y);
141 } 144 }
142 145
143 n += framesAvailableToCopy; 146 n += framesAvailableToCopy;
144 framesToProcess -= framesAvailableToCopy; 147 framesToProcess -= framesAvailableToCopy;
145 } 148 }
146 149
147 // Our work is done. Let the AudioContext know. 150 // Our work is done. Let the AudioContext know.
151 // See corresponding deref() call in notifyCompleteDispatch().
152 ref();
148 callOnMainThread(notifyCompleteDispatch, this); 153 callOnMainThread(notifyCompleteDispatch, this);
149 } 154 }
150 155
151 void OfflineAudioDestinationNode::notifyCompleteDispatch(void* userData) 156 void OfflineAudioDestinationNode::notifyCompleteDispatch(void* userData)
152 { 157 {
153 OfflineAudioDestinationNode* destinationNode = static_cast<OfflineAudioDesti nationNode*>(userData); 158 OfflineAudioDestinationNode* destinationNode = static_cast<OfflineAudioDesti nationNode*>(userData);
154 ASSERT(destinationNode); 159 ASSERT(destinationNode);
155 if (!destinationNode) 160 if (!destinationNode)
156 return; 161 return;
157 162
158 destinationNode->notifyComplete(); 163 destinationNode->notifyComplete();
159 destinationNode->deref(); 164 destinationNode->deref();
160 } 165 }
161 166
162 void OfflineAudioDestinationNode::notifyComplete() 167 void OfflineAudioDestinationNode::notifyComplete()
163 { 168 {
164 context()->fireCompletionEvent(); 169 context()->fireCompletionEvent();
165 } 170 }
166 171
167 } // namespace WebCore 172 } // namespace WebCore
168 173
169 #endif // ENABLE(WEB_AUDIO) 174 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698