| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 AudioDelayDSPKernel::AudioDelayDSPKernel(double maxDelayTime, float sampleRate) | 43 AudioDelayDSPKernel::AudioDelayDSPKernel(double maxDelayTime, float sampleRate) |
| 44 : AudioDSPKernel(sampleRate), | 44 : AudioDSPKernel(sampleRate), |
| 45 m_maxDelayTime(maxDelayTime), | 45 m_maxDelayTime(maxDelayTime), |
| 46 m_writeIndex(0), | 46 m_writeIndex(0), |
| 47 m_firstTime(true) { | 47 m_firstTime(true) { |
| 48 ASSERT(maxDelayTime > 0.0 && !std::isnan(maxDelayTime)); | 48 ASSERT(maxDelayTime > 0.0 && !std::isnan(maxDelayTime)); |
| 49 if (maxDelayTime <= 0.0 || std::isnan(maxDelayTime)) | 49 if (maxDelayTime <= 0.0 || std::isnan(maxDelayTime)) |
| 50 return; | 50 return; |
| 51 | 51 |
| 52 size_t bufferLength = bufferLengthForDelay(maxDelayTime, sampleRate); | 52 size_t bufferLength = bufferLengthForDelay(maxDelayTime, sampleRate); |
| 53 ASSERT(bufferLength); | 53 DCHECK(bufferLength); |
| 54 if (!bufferLength) | 54 if (!bufferLength) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 m_buffer.allocate(bufferLength); | 57 m_buffer.allocate(bufferLength); |
| 58 m_buffer.zero(); | 58 m_buffer.zero(); |
| 59 | 59 |
| 60 m_smoothingRate = AudioUtilities::discreteTimeConstantForSampleRate( | 60 m_smoothingRate = AudioUtilities::discreteTimeConstantForSampleRate( |
| 61 SmoothingTimeConstant, sampleRate); | 61 SmoothingTimeConstant, sampleRate); |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 80 double AudioDelayDSPKernel::delayTime(float sampleRate) { | 80 double AudioDelayDSPKernel::delayTime(float sampleRate) { |
| 81 return m_desiredDelayFrames / sampleRate; | 81 return m_desiredDelayFrames / sampleRate; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void AudioDelayDSPKernel::process(const float* source, | 84 void AudioDelayDSPKernel::process(const float* source, |
| 85 float* destination, | 85 float* destination, |
| 86 size_t framesToProcess) { | 86 size_t framesToProcess) { |
| 87 size_t bufferLength = m_buffer.size(); | 87 size_t bufferLength = m_buffer.size(); |
| 88 float* buffer = m_buffer.data(); | 88 float* buffer = m_buffer.data(); |
| 89 | 89 |
| 90 ASSERT(bufferLength); | 90 DCHECK(bufferLength); |
| 91 if (!bufferLength) | 91 if (!bufferLength) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 ASSERT(source && destination); | 94 ASSERT(source && destination); |
| 95 if (!source || !destination) | 95 if (!source || !destination) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 float sampleRate = this->sampleRate(); | 98 float sampleRate = this->sampleRate(); |
| 99 double delayTime = 0; | 99 double delayTime = 0; |
| 100 float* delayTimes = m_delayTimes.data(); | 100 float* delayTimes = m_delayTimes.data(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Account for worst case delay. | 163 // Account for worst case delay. |
| 164 // Don't try to track actual delay time which can change dynamically. | 164 // Don't try to track actual delay time which can change dynamically. |
| 165 return m_maxDelayTime; | 165 return m_maxDelayTime; |
| 166 } | 166 } |
| 167 | 167 |
| 168 double AudioDelayDSPKernel::latencyTime() const { | 168 double AudioDelayDSPKernel::latencyTime() const { |
| 169 return 0; | 169 return 0; |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |