| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WaveShaperProcessor::process(const AudioBus* source, AudioBus* destination,
size_t framesToProcess) | 72 void WaveShaperProcessor::process(const AudioBus* source, AudioBus* destination,
size_t framesToProcess) |
| 73 { | 73 { |
| 74 if (!isInitialized()) { | 74 if (!isInitialized()) { |
| 75 destination->zero(); | 75 destination->zero(); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool channelCountMatches = source->numberOfChannels() == destination->number
OfChannels() && source->numberOfChannels() == m_kernels.size(); | 79 bool channelCountMatches = source->numberOfChannels() == destination->number
OfChannels() && source->numberOfChannels() == m_kernels.size(); |
| 80 ASSERT(channelCountMatches); | 80 DCHECK(channelCountMatches); |
| 81 if (!channelCountMatches) | 81 if (!channelCountMatches) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 // The audio thread can't block on this lock, so we call tryLock() instead. | 84 // The audio thread can't block on this lock, so we call tryLock() instead. |
| 85 MutexTryLocker tryLocker(m_processLock); | 85 MutexTryLocker tryLocker(m_processLock); |
| 86 if (tryLocker.locked()) { | 86 if (tryLocker.locked()) { |
| 87 // For each channel of our input, process using the corresponding WaveSh
aperDSPKernel into the output channel. | 87 // For each channel of our input, process using the corresponding WaveSh
aperDSPKernel into the output channel. |
| 88 for (unsigned i = 0; i < m_kernels.size(); ++i) | 88 for (unsigned i = 0; i < m_kernels.size(); ++i) |
| 89 m_kernels[i]->process(source->channel(i)->data(), destination->chann
el(i)->mutableData(), framesToProcess); | 89 m_kernels[i]->process(source->channel(i)->data(), destination->chann
el(i)->mutableData(), framesToProcess); |
| 90 } else { | 90 } else { |
| 91 // Too bad - the tryLock() failed. We must be in the middle of a setCurv
e() call. | 91 // Too bad - the tryLock() failed. We must be in the middle of a setCurv
e() call. |
| 92 destination->zero(); | 92 destination->zero(); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace blink | 96 } // namespace blink |
| 97 | 97 |
| OLD | NEW |