| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 return adoptRef(new AudioBus(numberOfChannels, length, allocate)); | 55 return adoptRef(new AudioBus(numberOfChannels, length, allocate)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 AudioBus::AudioBus(unsigned numberOfChannels, size_t length, bool allocate) | 58 AudioBus::AudioBus(unsigned numberOfChannels, size_t length, bool allocate) |
| 59 : m_length(length), m_busGain(1), m_isFirstTime(true), m_sampleRate(0) { | 59 : m_length(length), m_busGain(1), m_isFirstTime(true), m_sampleRate(0) { |
| 60 m_channels.reserveInitialCapacity(numberOfChannels); | 60 m_channels.reserveInitialCapacity(numberOfChannels); |
| 61 | 61 |
| 62 for (unsigned i = 0; i < numberOfChannels; ++i) { | 62 for (unsigned i = 0; i < numberOfChannels; ++i) { |
| 63 std::unique_ptr<AudioChannel> channel = | 63 std::unique_ptr<AudioChannel> channel = |
| 64 allocate ? wrapUnique(new AudioChannel(length)) | 64 allocate ? WTF::wrapUnique(new AudioChannel(length)) |
| 65 : wrapUnique(new AudioChannel(0, length)); | 65 : WTF::wrapUnique(new AudioChannel(0, length)); |
| 66 m_channels.append(std::move(channel)); | 66 m_channels.append(std::move(channel)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 m_layout = LayoutCanonical; // for now this is the only layout we define | 69 m_layout = LayoutCanonical; // for now this is the only layout we define |
| 70 } | 70 } |
| 71 | 71 |
| 72 void AudioBus::setChannelMemory(unsigned channelIndex, | 72 void AudioBus::setChannelMemory(unsigned channelIndex, |
| 73 float* storage, | 73 float* storage, |
| 74 size_t length) { | 74 size_t length) { |
| 75 if (channelIndex < m_channels.size()) { | 75 if (channelIndex < m_channels.size()) { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 // Number of frames to de-zipper before we are close enough to the target | 518 // Number of frames to de-zipper before we are close enough to the target |
| 519 // gain. | 519 // gain. |
| 520 // FIXME: framesToDezipper could be smaller when target gain is close enough | 520 // FIXME: framesToDezipper could be smaller when target gain is close enough |
| 521 // within this process loop. | 521 // within this process loop. |
| 522 unsigned framesToDezipper = (gainDiff < epsilon) ? 0 : framesToProcess; | 522 unsigned framesToDezipper = (gainDiff < epsilon) ? 0 : framesToProcess; |
| 523 | 523 |
| 524 if (framesToDezipper) { | 524 if (framesToDezipper) { |
| 525 if (!m_dezipperGainValues.get() || | 525 if (!m_dezipperGainValues.get() || |
| 526 m_dezipperGainValues->size() < framesToDezipper) | 526 m_dezipperGainValues->size() < framesToDezipper) |
| 527 m_dezipperGainValues = makeUnique<AudioFloatArray>(framesToDezipper); | 527 m_dezipperGainValues = WTF::makeUnique<AudioFloatArray>(framesToDezipper); |
| 528 | 528 |
| 529 float* gainValues = m_dezipperGainValues->data(); | 529 float* gainValues = m_dezipperGainValues->data(); |
| 530 for (unsigned i = 0; i < framesToDezipper; ++i) { | 530 for (unsigned i = 0; i < framesToDezipper; ++i) { |
| 531 gain += (totalDesiredGain - gain) * DezipperRate; | 531 gain += (totalDesiredGain - gain) * DezipperRate; |
| 532 | 532 |
| 533 // FIXME: If we are clever enough in calculating the framesToDezipper | 533 // FIXME: If we are clever enough in calculating the framesToDezipper |
| 534 // value, we can probably get rid of this | 534 // value, we can probably get rid of this |
| 535 // DenormalDisabler::flushDenormalFloatToZero() call. | 535 // DenormalDisabler::flushDenormalFloatToZero() call. |
| 536 gain = DenormalDisabler::flushDenormalFloatToZero(gain); | 536 gain = DenormalDisabler::flushDenormalFloatToZero(gain); |
| 537 *gainValues++ = gain; | 537 *gainValues++ = gain; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 // If the bus needs no conversion then return as is. | 758 // If the bus needs no conversion then return as is. |
| 759 if ((!mixToMono || audioBus->numberOfChannels() == 1) && | 759 if ((!mixToMono || audioBus->numberOfChannels() == 1) && |
| 760 audioBus->sampleRate() == sampleRate) | 760 audioBus->sampleRate() == sampleRate) |
| 761 return audioBus; | 761 return audioBus; |
| 762 | 762 |
| 763 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, | 763 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, |
| 764 sampleRate); | 764 sampleRate); |
| 765 } | 765 } |
| 766 | 766 |
| 767 } // namespace blink | 767 } // namespace blink |
| OLD | NEW |