cts_audio work: initial code
- volume calibration and THD test case work tuned.
- 59 unit tests pass
- local audio playback / recording works : uses tinyalsa
- host to device ptorocol in host side implemented / tested (with loopback)
- device side recording / playback works for test cases / test_io.xml
- python processing baseline added.
- spectrum algorithm implementated: calculate Transfer Function of device
over host and check if amplitudes are within margain. Needs parameter tuning
- spectrum test needs some improvements due to the non-flat response from
ref microphone.
- build is enabled only for linux host except the client code
Change-Id: I8453ac72b6fce7ddbfee7e2cc05207f09f2b3d88
diff --git a/suite/audio_quality/lib/src/StringUtil.cpp b/suite/audio_quality/lib/src/StringUtil.cpp
new file mode 100644
index 0000000..f23a29a
--- /dev/null
+++ b/suite/audio_quality/lib/src/StringUtil.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "Log.h"
+#include "StringUtil.h"
+
+std::vector<android::String8>* StringUtil::split(const android::String8& str, char delimiter)
+{
+ std::vector<android::String8>* tokens = new std::vector<android::String8>();
+ unsigned int lastTokenEnd = 0;
+ for (unsigned int i = 0; i < str.length(); i++) {
+ if (str[i] == delimiter) {
+ if ((i - lastTokenEnd) > 0) {
+ tokens->push_back(substr(str, lastTokenEnd, i - lastTokenEnd));
+ }
+ lastTokenEnd = i + 1; // 1 for skipping delimiter
+ }
+ }
+ if (lastTokenEnd < str.length()) {
+ tokens->push_back(substr(str, lastTokenEnd, str.length() - lastTokenEnd));
+ }
+ return tokens;
+}
+
+android::String8 StringUtil::substr(const android::String8& str, size_t pos, size_t n)
+{
+ size_t l = str.length();
+
+ if (pos >= l) {
+ android::String8 resultDummy;
+ return resultDummy;
+ }
+ if ((pos + n) > l) {
+ n = l - pos;
+ }
+ android::String8 result(str.string() + pos, n);
+ return result;
+}
+
+int StringUtil::compare(const android::String8& str, const char* other)
+{
+ return strcmp(str.string(), other);
+}
+
+bool StringUtil::endsWith(const android::String8& str, const char* other)
+{
+ size_t l1 = str.length();
+ size_t l2 = strlen(other);
+ const char* data = str.string();
+ if (l2 > l1) {
+ return false;
+ }
+ size_t iStr = l1 - l2;
+ size_t iOther = 0;
+ for(; iStr < l1; iStr++) {
+ if (data[iStr] != other[iOther]) {
+ return false;
+ }
+ iOther++;
+ }
+ return true;
+}