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

Unified Diff: media/base/audio_hash.cc

Issue 1727953005: Enable AudioDecoder unit tests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed contitions from base/container_names.* compilation Created 4 years, 10 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_hash.h ('k') | media/filters/audio_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_hash.cc
diff --git a/media/base/audio_hash.cc b/media/base/audio_hash.cc
index d879e5453629ff1f4e08a4b37c1ed71e1d6b9324..7f133dd78ba086bcf0d0109ff89b35610c6b0561 100644
--- a/media/base/audio_hash.cc
+++ b/media/base/audio_hash.cc
@@ -5,6 +5,7 @@
// MSVC++ requires this to be set before any other includes to get M_PI.
#define _USE_MATH_DEFINES
#include <cmath>
+#include <sstream>
#include "media/base/audio_hash.h"
@@ -52,4 +53,17 @@ std::string AudioHash::ToString() const {
return result;
}
+bool AudioHash::IsEquivalent(const std::string& other, double tolerance) const {
+ float other_hash;
+ char comma;
+
+ std::stringstream is(other);
+ for (size_t i = 0; i < arraysize(audio_hash_); ++i) {
+ is >> other_hash >> comma;
+ if (fabs(audio_hash_[i] - other_hash) > tolerance)
+ return false;
+ }
+ return true;
+}
+
} // namespace media
« no previous file with comments | « media/base/audio_hash.h ('k') | media/filters/audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698