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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_bus.h ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_bus.cc
diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc
index 0dc3300b8defc9e3964555df11d049e8892715ab..43dd341001c645fc8ea6c696dc505049ff75a137 100644
--- a/media/base/audio_bus.cc
+++ b/media/base/audio_bus.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "media/audio/audio_parameters.h"
#include "media/base/limits.h"
+#include "media/base/vector_math.h"
namespace media {
@@ -307,4 +308,13 @@ void AudioBus::CopyTo(AudioBus* dest) const {
memcpy(dest->channel(i), channel(i), sizeof(*channel(i)) * frames());
}
+void AudioBus::Scale(float volume) {
+ if (volume > 0 && volume != 1) {
+ for (int i = 0; i < channels(); ++i)
+ vector_math::FMUL(channel(i), volume, frames(), channel(i));
+ } else if (volume == 0) {
+ Zero();
+ }
+}
+
} // namespace media
« 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