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

Side by Side Diff: media/audio/audio_util.cc

Issue 10824304: Upgrade AudioBus to support wrapping, interleaving. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lint. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/audio_bus.h » ('j') | media/base/audio_bus.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Software adjust volume of samples, allows each audio stream its own 5 // Software adjust volume of samples, allows each audio stream its own
6 // volume without impacting master volume for chrome and other applications. 6 // volume without impacting master volume for chrome and other applications.
7 7
8 // Implemented as templates to allow 8, 16 and 32 bit implementations. 8 // Implemented as templates to allow 8, 16 and 32 bit implementations.
9 // 8 bit is unsigned and biased by 128. 9 // 8 bit is unsigned and biased by 128.
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 reinterpret_cast<int32*>(buf), 175 reinterpret_cast<int32*>(buf),
176 sample_count, 176 sample_count,
177 volume, 177 volume,
178 channels); 178 channels);
179 return true; 179 return true;
180 } 180 }
181 } 181 }
182 return false; 182 return false;
183 } 183 }
184 184
185 // TODO(dalecurtis): Delete once everywhere is using the AudioBus version.
185 bool DeinterleaveAudioChannel(void* source, 186 bool DeinterleaveAudioChannel(void* source,
186 float* destination, 187 float* destination,
187 int channels, 188 int channels,
188 int channel_index, 189 int channel_index,
189 int bytes_per_sample, 190 int bytes_per_sample,
190 size_t number_of_frames) { 191 size_t number_of_frames) {
191 switch (bytes_per_sample) { 192 switch (bytes_per_sample) {
192 case 1: 193 case 1:
193 { 194 {
194 uint8* source8 = reinterpret_cast<uint8*>(source) + channel_index; 195 uint8* source8 = reinterpret_cast<uint8*>(source) + channel_index;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (sample > max_value) 253 if (sample > max_value)
253 sample = max_value; 254 sample = max_value;
254 else if (sample < min_value) 255 else if (sample < min_value)
255 sample = min_value; 256 sample = min_value;
256 257
257 destination[j * channels + i] = static_cast<Format>(sample) + bias; 258 destination[j * channels + i] = static_cast<Format>(sample) + bias;
258 } 259 }
259 } 260 }
260 } 261 }
261 262
263 // TODO(dalecurtis): Delete once everywhere is using the AudioBus version.
262 void InterleaveFloatToInt(const AudioBus* source, void* dst, 264 void InterleaveFloatToInt(const AudioBus* source, void* dst,
263 size_t number_of_frames, int bytes_per_sample) { 265 size_t number_of_frames, int bytes_per_sample) {
264 switch (bytes_per_sample) { 266 switch (bytes_per_sample) {
265 case 1: 267 case 1:
266 InterleaveFloatToInt<uint8, int32>(source, dst, number_of_frames); 268 InterleaveFloatToInt<uint8, int32>(source, dst, number_of_frames);
267 break; 269 break;
268 case 2: 270 case 2:
269 InterleaveFloatToInt<int16, int32>(source, dst, number_of_frames); 271 InterleaveFloatToInt<int16, int32>(source, dst, number_of_frames);
270 break; 272 break;
271 case 4: 273 case 4:
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // out performance was degraded compared to XP. 549 // out performance was degraded compared to XP.
548 // - The regression was fixed in Windows 7 and most configurations will work 550 // - The regression was fixed in Windows 7 and most configurations will work
549 // with 2, but some (e.g., some Sound Blasters) still need 3. 551 // with 2, but some (e.g., some Sound Blasters) still need 3.
550 // - Some XP configurations (even multi-processor ones) also need 3. 552 // - Some XP configurations (even multi-processor ones) also need 3.
551 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3; 553 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3;
552 } 554 }
553 555
554 #endif 556 #endif
555 557
556 } // namespace media 558 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_bus.h » ('j') | media/base/audio_bus.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698