Chromium Code Reviews| Index: Source/core/platform/audio/AudioDSPKernelProcessor.cpp |
| diff --git a/Source/core/platform/audio/AudioDSPKernelProcessor.cpp b/Source/core/platform/audio/AudioDSPKernelProcessor.cpp |
| index 0875464968f0ca5e4b05204984eafa73a8117d15..5a8c20f7adb4dff01cba23060d7f7ac3783bd2c2 100644 |
| --- a/Source/core/platform/audio/AudioDSPKernelProcessor.cpp |
| +++ b/Source/core/platform/audio/AudioDSPKernelProcessor.cpp |
| @@ -50,6 +50,7 @@ void AudioDSPKernelProcessor::initialize() |
| if (isInitialized()) |
| return; |
| + MutexLocker locker(m_processLock); |
| ASSERT(!m_kernels.size()); |
| // Create processing kernels, one per channel. |
| @@ -65,6 +66,7 @@ void AudioDSPKernelProcessor::uninitialize() |
| if (!isInitialized()) |
| return; |
| + MutexLocker locker(m_processLock); |
| m_kernels.clear(); |
| m_initialized = false; |
| @@ -81,13 +83,20 @@ void AudioDSPKernelProcessor::process(const AudioBus* source, AudioBus* destinat |
| return; |
| } |
| - bool channelCountMatches = source->numberOfChannels() == destination->numberOfChannels() && source->numberOfChannels() == m_kernels.size(); |
| - ASSERT(channelCountMatches); |
| - if (!channelCountMatches) |
| - return; |
| - |
| - for (unsigned i = 0; i < m_kernels.size(); ++i) |
| - m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->mutableData(), framesToProcess); |
| + MutexTryLocker tryLocker(m_processLock); |
| + if (tryLocker.locked()) { |
| + bool channelCountMatches = source->numberOfChannels() == destination->numberOfChannels() && source->numberOfChannels() == m_kernels.size(); |
| + ASSERT(channelCountMatches); |
| + if (!channelCountMatches) |
| + return; |
| + |
| + for (unsigned i = 0; i < m_kernels.size(); ++i) |
| + m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->mutableData(), framesToProcess); |
| + } else { |
| + // Unfortunately, the kernel is being processed by another thread. |
| + // See also ConvolverNode::process(). |
| + destination->zero(); |
| + } |
| } |
| // Resets filter state |
| @@ -100,6 +109,7 @@ void AudioDSPKernelProcessor::reset() |
| // Any processing depending on this value must set it to false at the appropriate time. |
| m_hasJustReset = true; |
| + MutexLocker locker(m_processLock); |
| for (unsigned i = 0; i < m_kernels.size(); ++i) |
| m_kernels[i]->reset(); |
| } |
| @@ -116,12 +126,14 @@ void AudioDSPKernelProcessor::setNumberOfChannels(unsigned numberOfChannels) |
| double AudioDSPKernelProcessor::tailTime() const |
| { |
| + MutexLocker locker(m_processLock); |
|
Ken Russell (switch to Gerrit)
2013/09/04 18:18:46
I believe this is called on the audio thread and t
haraken
2013/09/04 19:50:05
Done.
|
| // It is expected that all the kernels have the same tailTime. |
| return !m_kernels.isEmpty() ? m_kernels.first()->tailTime() : 0; |
| } |
| double AudioDSPKernelProcessor::latencyTime() const |
| { |
| + MutexLocker locker(m_processLock); |
|
Ken Russell (switch to Gerrit)
2013/09/04 18:18:46
trylock needed here too.
haraken
2013/09/04 19:50:05
Done.
|
| // It is expected that all the kernels have the same latencyTime. |
| return !m_kernels.isEmpty() ? m_kernels.first()->latencyTime() : 0; |
| } |