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 28 matching lines...) Expand all Loading... |
39 { | 39 { |
40 if (isInitialized()) | 40 if (isInitialized()) |
41 uninitialize(); | 41 uninitialize(); |
42 } | 42 } |
43 | 43 |
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(const float* curveData, unsigned curveLength) |
50 { | 50 { |
| 51 DCHECK(isMainThread()); |
| 52 |
51 // This synchronizes with process(). | 53 // This synchronizes with process(). |
52 MutexLocker processLocker(m_processLock); | 54 MutexLocker processLocker(m_processLock); |
53 | 55 |
54 // Copy the curve data, if any, to our internal buffer. | 56 if (curveLength == 0 || !curveData) { |
55 if (!curve) { | |
56 m_curve = nullptr; | 57 m_curve = nullptr; |
57 return; | 58 return; |
58 } | 59 } |
59 | 60 |
60 m_curve = wrapUnique(new Vector<float>(curve->length())); | 61 // Copy the curve data, if any, to our internal buffer. |
61 memcpy(m_curve->data(), curve->data(), sizeof(float)*curve->length()); | 62 m_curve = wrapUnique(new Vector<float>(curveLength)); |
| 63 memcpy(m_curve->data(), curveData, sizeof(float)*curveLength); |
62 } | 64 } |
63 | 65 |
64 void WaveShaperProcessor::setOversample(OverSampleType oversample) | 66 void WaveShaperProcessor::setOversample(OverSampleType oversample) |
65 { | 67 { |
66 // This synchronizes with process(). | 68 // This synchronizes with process(). |
67 MutexLocker processLocker(m_processLock); | 69 MutexLocker processLocker(m_processLock); |
68 | 70 |
69 m_oversample = oversample; | 71 m_oversample = oversample; |
70 | 72 |
71 if (oversample != OverSampleNone) { | 73 if (oversample != OverSampleNone) { |
(...skipping 23 matching lines...) Expand all Loading... |
95 for (unsigned i = 0; i < m_kernels.size(); ++i) | 97 for (unsigned i = 0; i < m_kernels.size(); ++i) |
96 m_kernels[i]->process(source->channel(i)->data(), destination->chann
el(i)->mutableData(), framesToProcess); | 98 m_kernels[i]->process(source->channel(i)->data(), destination->chann
el(i)->mutableData(), framesToProcess); |
97 } else { | 99 } else { |
98 // Too bad - the tryLock() failed. We must be in the middle of a setCurv
e() call. | 100 // Too bad - the tryLock() failed. We must be in the middle of a setCurv
e() call. |
99 destination->zero(); | 101 destination->zero(); |
100 } | 102 } |
101 } | 103 } |
102 | 104 |
103 } // namespace blink | 105 } // namespace blink |
104 | 106 |
OLD | NEW |