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

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

Issue 2223613002: WaveShaperNode should copy its curve. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 4 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 | « third_party/WebKit/Source/modules/webaudio/WaveShaperProcessor.h ('k') | 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 std::unique_ptr<AudioDSPKernel> WaveShaperProcessor::createKernel() 44 std::unique_ptr<AudioDSPKernel> WaveShaperProcessor::createKernel()
45 { 45 {
46 return wrapUnique(new WaveShaperDSPKernel(this)); 46 return wrapUnique(new WaveShaperDSPKernel(this));
47 } 47 }
48 48
49 void WaveShaperProcessor::setCurve(DOMFloat32Array* curve) 49 void WaveShaperProcessor::setCurve(DOMFloat32Array* curve)
50 { 50 {
51 // This synchronizes with process(). 51 // This synchronizes with process().
52 MutexLocker processLocker(m_processLock); 52 MutexLocker processLocker(m_processLock);
53 53
54 m_curve = curve; 54 // Copy the curve data, if any, to our internal buffer.
55 if (!curve) {
56 m_curve = nullptr;
57 return;
58 }
59
60 m_curve = wrapUnique(new Vector<float>(curve->length()));
61 memcpy(m_curve->data(), curve->data(), sizeof(float)*curve->length());
55 } 62 }
56 63
57 void WaveShaperProcessor::setOversample(OverSampleType oversample) 64 void WaveShaperProcessor::setOversample(OverSampleType oversample)
58 { 65 {
59 // This synchronizes with process(). 66 // This synchronizes with process().
60 MutexLocker processLocker(m_processLock); 67 MutexLocker processLocker(m_processLock);
61 68
62 m_oversample = oversample; 69 m_oversample = oversample;
63 70
64 if (oversample != OverSampleNone) { 71 if (oversample != OverSampleNone) {
(...skipping 23 matching lines...) Expand all
88 for (unsigned i = 0; i < m_kernels.size(); ++i) 95 for (unsigned i = 0; i < m_kernels.size(); ++i)
89 m_kernels[i]->process(source->channel(i)->data(), destination->chann el(i)->mutableData(), framesToProcess); 96 m_kernels[i]->process(source->channel(i)->data(), destination->chann el(i)->mutableData(), framesToProcess);
90 } else { 97 } else {
91 // Too bad - the tryLock() failed. We must be in the middle of a setCurv e() call. 98 // Too bad - the tryLock() failed. We must be in the middle of a setCurv e() call.
92 destination->zero(); 99 destination->zero();
93 } 100 }
94 } 101 }
95 102
96 } // namespace blink 103 } // namespace blink
97 104
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/WaveShaperProcessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698