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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/IIRProcessor.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webaudio/IIRProcessor.h" 5 #include "modules/webaudio/IIRProcessor.h"
6 6
7 #include "modules/webaudio/IIRDSPKernel.h" 7 #include "modules/webaudio/IIRDSPKernel.h"
8 #include "wtf/PtrUtil.h"
9 #include <memory>
8 10
9 namespace blink { 11 namespace blink {
10 12
11 IIRProcessor::IIRProcessor(float sampleRate, size_t numberOfChannels, const Vect or<double>& feedforwardCoef, const Vector<double>& feedbackCoef) 13 IIRProcessor::IIRProcessor(float sampleRate, size_t numberOfChannels, const Vect or<double>& feedforwardCoef, const Vector<double>& feedbackCoef)
12 : AudioDSPKernelProcessor(sampleRate, numberOfChannels) 14 : AudioDSPKernelProcessor(sampleRate, numberOfChannels)
13 { 15 {
14 unsigned feedbackLength = feedbackCoef.size(); 16 unsigned feedbackLength = feedbackCoef.size();
15 unsigned feedforwardLength = feedforwardCoef.size(); 17 unsigned feedforwardLength = feedforwardCoef.size();
16 ASSERT(feedbackLength > 0); 18 ASSERT(feedbackLength > 0);
17 ASSERT(feedforwardLength > 0); 19 ASSERT(feedforwardLength > 0);
(...skipping 21 matching lines...) Expand all
39 for (unsigned k = 1; k < feedbackLength; ++k) 41 for (unsigned k = 1; k < feedbackLength; ++k)
40 m_feedback[k] /= scale; 42 m_feedback[k] /= scale;
41 43
42 for (unsigned k = 0; k < feedforwardLength; ++k) 44 for (unsigned k = 0; k < feedforwardLength; ++k)
43 m_feedforward[k] /= scale; 45 m_feedforward[k] /= scale;
44 46
45 // The IIRFilter checks to make sure this coefficient is 1, so make it s o. 47 // The IIRFilter checks to make sure this coefficient is 1, so make it s o.
46 m_feedback[0] = 1; 48 m_feedback[0] = 1;
47 } 49 }
48 50
49 m_responseKernel = adoptPtr(new IIRDSPKernel(this)); 51 m_responseKernel = wrapUnique(new IIRDSPKernel(this));
50 } 52 }
51 53
52 IIRProcessor::~IIRProcessor() 54 IIRProcessor::~IIRProcessor()
53 { 55 {
54 if (isInitialized()) 56 if (isInitialized())
55 uninitialize(); 57 uninitialize();
56 } 58 }
57 59
58 PassOwnPtr<AudioDSPKernel> IIRProcessor::createKernel() 60 std::unique_ptr<AudioDSPKernel> IIRProcessor::createKernel()
59 { 61 {
60 return adoptPtr(new IIRDSPKernel(this)); 62 return wrapUnique(new IIRDSPKernel(this));
61 } 63 }
62 64
63 void IIRProcessor::process(const AudioBus* source, AudioBus* destination, size_t framesToProcess) 65 void IIRProcessor::process(const AudioBus* source, AudioBus* destination, size_t framesToProcess)
64 { 66 {
65 if (!isInitialized()) { 67 if (!isInitialized()) {
66 destination->zero(); 68 destination->zero();
67 return; 69 return;
68 } 70 }
69 71
70 // For each channel of our input, process using the corresponding IIRDSPKern el into the output 72 // For each channel of our input, process using the corresponding IIRDSPKern el into the output
71 // channel. 73 // channel.
72 for (unsigned i = 0; i < m_kernels.size(); ++i) 74 for (unsigned i = 0; i < m_kernels.size(); ++i)
73 m_kernels[i]->process(source->channel(i)->data(), destination->channel(i )->mutableData(), framesToProcess); 75 m_kernels[i]->process(source->channel(i)->data(), destination->channel(i )->mutableData(), framesToProcess);
74 } 76 }
75 77
76 void IIRProcessor::getFrequencyResponse(int nFrequencies, const float* frequency Hz, float* magResponse, float* phaseResponse) 78 void IIRProcessor::getFrequencyResponse(int nFrequencies, const float* frequency Hz, float* magResponse, float* phaseResponse)
77 { 79 {
78 m_responseKernel->getFrequencyResponse(nFrequencies, frequencyHz, magRespons e, phaseResponse); 80 m_responseKernel->getFrequencyResponse(nFrequencies, frequencyHz, magRespons e, phaseResponse);
79 } 81 }
80 82
81 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698