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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ? WTF::wrapUnique(new AudioChannel(length)) | 64 allocate ? WTF::wrapUnique(new AudioChannel(length)) |
65 : WTF::wrapUnique(new AudioChannel(0, length)); | 65 : WTF::wrapUnique(new AudioChannel(0, length)); |
66 m_channels.append(std::move(channel)); | 66 m_channels.push_back(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()) { |
76 channel(channelIndex)->set(storage, length); | 76 channel(channelIndex)->set(storage, length); |
(...skipping 681 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 |