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

Unified Diff: media/base/audio_bus_unittest.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.cc ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_bus_unittest.cc
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc
index 8c3a59f4efa103eb406302f7204c19e3d8350495..562d760b8dc17cc6cbd99dbe2f388034211dd9b8 100644
--- a/media/base/audio_bus_unittest.cc
+++ b/media/base/audio_bus_unittest.cc
@@ -356,4 +356,35 @@ TEST_F(AudioBusTest, ToInterleavedPartial) {
kPartialFrames * sizeof(*kTestVectorInt16) * kTestVectorChannels), 0);
}
+TEST_F(AudioBusTest, Scale) {
+ scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, kFrameCount);
+
+ // Fill the bus with dummy data.
+ static const float kFillValue = 1;
+ for (int i = 0; i < bus->channels(); ++i)
+ std::fill(bus->channel(i), bus->channel(i) + bus->frames(), kFillValue);
+
+ // Adjust by an invalid volume and ensure volume is unchanged.
+ bus->Scale(-1);
+ for (int i = 0; i < bus->channels(); ++i) {
+ SCOPED_TRACE("Invalid Scale");
+ VerifyValue(bus->channel(i), bus->frames(), kFillValue);
+ }
+
+ // Verify correct volume adjustment.
+ static const float kVolume = 0.5;
+ bus->Scale(kVolume);
+ for (int i = 0; i < bus->channels(); ++i) {
+ SCOPED_TRACE("Half Scale");
+ VerifyValue(bus->channel(i), bus->frames(), kFillValue * kVolume);
+ }
+
+ // Verify zero volume case.
+ bus->Scale(0);
+ for (int i = 0; i < bus->channels(); ++i) {
+ SCOPED_TRACE("Zero Scale");
+ VerifyValue(bus->channel(i), bus->frames(), 0);
+ }
+}
+
} // namespace media
« no previous file with comments | « media/base/audio_bus.cc ('k') | media/base/audio_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698