Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: Source/modules/webaudio/AudioBuffer.cpp

Issue 190973010: Remove unnecessary attribute "gain" in AudioBuffer and AudioBufferSourceNode interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Combine with removing gains from AudioBuffer and AudioBufferSourceNode Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 return nullptr; 76 return nullptr;
77 } 77 }
78 78
79 bool AudioBuffer::createdSuccessfully(unsigned desiredNumberOfChannels) const 79 bool AudioBuffer::createdSuccessfully(unsigned desiredNumberOfChannels) const
80 { 80 {
81 return numberOfChannels() == desiredNumberOfChannels; 81 return numberOfChannels() == desiredNumberOfChannels;
82 } 82 }
83 83
84 AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate) 84 AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
85 : m_gain(1.0) 85 : m_sampleRate(sampleRate)
86 , m_sampleRate(sampleRate)
87 , m_length(numberOfFrames) 86 , m_length(numberOfFrames)
88 { 87 {
89 ScriptWrappable::init(this); 88 ScriptWrappable::init(this);
90 m_channels.reserveCapacity(numberOfChannels); 89 m_channels.reserveCapacity(numberOfChannels);
91 90
92 for (unsigned i = 0; i < numberOfChannels; ++i) { 91 for (unsigned i = 0; i < numberOfChannels; ++i) {
93 RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length); 92 RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length);
94 // If the channel data array could not be created, just return. The call er will need to 93 // If the channel data array could not be created, just return. The call er will need to
95 // check that the desired number of channels were created. 94 // check that the desired number of channels were created.
96 if (!channelDataArray) { 95 if (!channelDataArray) {
97 return; 96 return;
98 } 97 }
99 98
100 channelDataArray->setNeuterable(false); 99 channelDataArray->setNeuterable(false);
101 m_channels.append(channelDataArray); 100 m_channels.append(channelDataArray);
102 } 101 }
103 } 102 }
104 103
105 AudioBuffer::AudioBuffer(AudioBus* bus) 104 AudioBuffer::AudioBuffer(AudioBus* bus)
106 : m_gain(1.0) 105 : m_sampleRate(bus->sampleRate())
107 , m_sampleRate(bus->sampleRate())
108 , m_length(bus->length()) 106 , m_length(bus->length())
109 { 107 {
110 ScriptWrappable::init(this); 108 ScriptWrappable::init(this);
111 // Copy audio data from the bus to the Float32Arrays we manage. 109 // Copy audio data from the bus to the Float32Arrays we manage.
112 unsigned numberOfChannels = bus->numberOfChannels(); 110 unsigned numberOfChannels = bus->numberOfChannels();
113 m_channels.reserveCapacity(numberOfChannels); 111 m_channels.reserveCapacity(numberOfChannels);
114 for (unsigned i = 0; i < numberOfChannels; ++i) { 112 for (unsigned i = 0; i < numberOfChannels; ++i) {
115 RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length); 113 RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length);
116 // If the channel data array could not be created, just return. The call er will need to 114 // If the channel data array could not be created, just return. The call er will need to
117 // check that the desired number of channels were created. 115 // check that the desired number of channels were created.
(...skipping 29 matching lines...) Expand all
147 { 145 {
148 for (unsigned i = 0; i < m_channels.size(); ++i) { 146 for (unsigned i = 0; i < m_channels.size(); ++i) {
149 if (getChannelData(i)) 147 if (getChannelData(i))
150 getChannelData(i)->zeroRange(0, length()); 148 getChannelData(i)->zeroRange(0, length());
151 } 149 }
152 } 150 }
153 151
154 } // namespace WebCore 152 } // namespace WebCore
155 153
156 #endif // ENABLE(WEB_AUDIO) 154 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698