| 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 PassRefPtr<AudioBus> AudioBus::createBufferFromRange( | 187 PassRefPtr<AudioBus> AudioBus::createBufferFromRange( |
| 188 const AudioBus* sourceBuffer, | 188 const AudioBus* sourceBuffer, |
| 189 unsigned startFrame, | 189 unsigned startFrame, |
| 190 unsigned endFrame) { | 190 unsigned endFrame) { |
| 191 size_t numberOfSourceFrames = sourceBuffer->length(); | 191 size_t numberOfSourceFrames = sourceBuffer->length(); |
| 192 unsigned numberOfChannels = sourceBuffer->numberOfChannels(); | 192 unsigned numberOfChannels = sourceBuffer->numberOfChannels(); |
| 193 | 193 |
| 194 // Sanity checking | 194 // Sanity checking |
| 195 bool isRangeSafe = startFrame < endFrame && endFrame <= numberOfSourceFrames; | 195 bool isRangeSafe = startFrame < endFrame && endFrame <= numberOfSourceFrames; |
| 196 ASSERT(isRangeSafe); | 196 DCHECK(isRangeSafe); |
| 197 if (!isRangeSafe) | 197 if (!isRangeSafe) |
| 198 return nullptr; | 198 return nullptr; |
| 199 | 199 |
| 200 size_t rangeLength = endFrame - startFrame; | 200 size_t rangeLength = endFrame - startFrame; |
| 201 | 201 |
| 202 RefPtr<AudioBus> audioBus = create(numberOfChannels, rangeLength); | 202 RefPtr<AudioBus> audioBus = create(numberOfChannels, rangeLength); |
| 203 audioBus->setSampleRate(sourceBuffer->sampleRate()); | 203 audioBus->setSampleRate(sourceBuffer->sampleRate()); |
| 204 | 204 |
| 205 for (unsigned i = 0; i < numberOfChannels; ++i) | 205 for (unsigned i = 0; i < numberOfChannels; ++i) |
| 206 audioBus->channel(i)->copyFromRange(sourceBuffer->channel(i), startFrame, | 206 audioBus->channel(i)->copyFromRange(sourceBuffer->channel(i), startFrame, |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 // If the bus needs no conversion then return as is. | 759 // If the bus needs no conversion then return as is. |
| 760 if ((!mixToMono || audioBus->numberOfChannels() == 1) && | 760 if ((!mixToMono || audioBus->numberOfChannels() == 1) && |
| 761 audioBus->sampleRate() == sampleRate) | 761 audioBus->sampleRate() == sampleRate) |
| 762 return audioBus; | 762 return audioBus; |
| 763 | 763 |
| 764 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, | 764 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, |
| 765 sampleRate); | 765 sampleRate); |
| 766 } | 766 } |
| 767 | 767 |
| 768 } // namespace blink | 768 } // namespace blink |
| OLD | NEW |