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

Side by Side Diff: Source/core/platform/audio/Reverb.cpp

Issue 14628008: Require use of AudioBus::create() to avoid ref-counting issues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Require use of Created 7 years, 7 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
OLDNEW
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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 OwnPtr<ReverbConvolver> convolver = adoptPtr(new ReverbConvolver(channel , renderSliceSize, maxFFTSize, convolverRenderPhase, useBackgroundThreads)); 126 OwnPtr<ReverbConvolver> convolver = adoptPtr(new ReverbConvolver(channel , renderSliceSize, maxFFTSize, convolverRenderPhase, useBackgroundThreads));
127 m_convolvers.append(convolver.release()); 127 m_convolvers.append(convolver.release());
128 128
129 convolverRenderPhase += renderSliceSize; 129 convolverRenderPhase += renderSliceSize;
130 } 130 }
131 131
132 // For "True" stereo processing we allocate a temporary buffer to avoid repe atedly allocating it in the process() method. 132 // For "True" stereo processing we allocate a temporary buffer to avoid repe atedly allocating it in the process() method.
133 // It can be bad to allocate memory in a real-time thread. 133 // It can be bad to allocate memory in a real-time thread.
134 if (numResponseChannels == 4) 134 if (numResponseChannels == 4)
135 m_tempBuffer = adoptRef(new AudioBus(2, MaxFrameSize)); 135 m_tempBuffer = AudioBus::create(2, MaxFrameSize);
136 } 136 }
137 137
138 void Reverb::process(const AudioBus* sourceBus, AudioBus* destinationBus, size_t framesToProcess) 138 void Reverb::process(const AudioBus* sourceBus, AudioBus* destinationBus, size_t framesToProcess)
139 { 139 {
140 // Do a fairly comprehensive sanity check. 140 // Do a fairly comprehensive sanity check.
141 // If these conditions are satisfied, all of the source and destination poin ters will be valid for the various matrixing cases. 141 // If these conditions are satisfied, all of the source and destination poin ters will be valid for the various matrixing cases.
142 bool isSafeToProcess = sourceBus && destinationBus && sourceBus->numberOfCha nnels() > 0 && destinationBus->numberOfChannels() > 0 142 bool isSafeToProcess = sourceBus && destinationBus && sourceBus->numberOfCha nnels() > 0 && destinationBus->numberOfChannels() > 0
143 && framesToProcess <= MaxFrameSize && framesToProcess <= sourceBus->leng th() && framesToProcess <= destinationBus->length(); 143 && framesToProcess <= MaxFrameSize && framesToProcess <= sourceBus->leng th() && framesToProcess <= destinationBus->length();
144 144
145 ASSERT(isSafeToProcess); 145 ASSERT(isSafeToProcess);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 235
236 size_t Reverb::latencyFrames() const 236 size_t Reverb::latencyFrames() const
237 { 237 {
238 return !m_convolvers.isEmpty() ? m_convolvers.first()->latencyFrames() : 0; 238 return !m_convolvers.isEmpty() ? m_convolvers.first()->latencyFrames() : 0;
239 } 239 }
240 240
241 } // namespace WebCore 241 } // namespace WebCore
242 242
243 #endif // ENABLE(WEB_AUDIO) 243 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/core/platform/audio/MultiChannelResampler.cpp ('k') | Source/core/platform/audio/SincResampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698