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

Side by Side Diff: media/base/audio_bus.cc

Issue 13726011: Add vector_math::FMUL. Replace audio_util::AdjustVolume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix volume == 1 case. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_bus.h ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »
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 #include "media/base/audio_bus.h" 5 #include "media/base/audio_bus.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
11 #include "media/base/limits.h" 11 #include "media/base/limits.h"
12 #include "media/base/vector_math.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 static bool IsAligned(void* ptr) { 16 static bool IsAligned(void* ptr) {
16 return (reinterpret_cast<uintptr_t>(ptr) & 17 return (reinterpret_cast<uintptr_t>(ptr) &
17 (AudioBus::kChannelAlignment - 1)) == 0U; 18 (AudioBus::kChannelAlignment - 1)) == 0U;
18 } 19 }
19 20
20 // Calculates the required size for an AudioBus with the given params, sets 21 // Calculates the required size for an AudioBus with the given params, sets
21 // |aligned_frames| to the actual frame length of each channel array. 22 // |aligned_frames| to the actual frame length of each channel array.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 void AudioBus::CopyTo(AudioBus* dest) const { 301 void AudioBus::CopyTo(AudioBus* dest) const {
301 CHECK_EQ(channels(), dest->channels()); 302 CHECK_EQ(channels(), dest->channels());
302 CHECK_EQ(frames(), dest->frames()); 303 CHECK_EQ(frames(), dest->frames());
303 304
304 // Since we don't know if the other AudioBus is wrapped or not (and we don't 305 // Since we don't know if the other AudioBus is wrapped or not (and we don't
305 // want to care), just copy using the public channel() accessors. 306 // want to care), just copy using the public channel() accessors.
306 for (int i = 0; i < channels(); ++i) 307 for (int i = 0; i < channels(); ++i)
307 memcpy(dest->channel(i), channel(i), sizeof(*channel(i)) * frames()); 308 memcpy(dest->channel(i), channel(i), sizeof(*channel(i)) * frames());
308 } 309 }
309 310
311 void AudioBus::Scale(float volume) {
312 if (volume > 0 && volume != 1) {
313 for (int i = 0; i < channels(); ++i)
314 vector_math::FMUL(channel(i), volume, frames(), channel(i));
315 } else if (volume == 0) {
316 Zero();
317 }
318 }
319
310 } // namespace media 320 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.h ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698