Merge changes from topic "64-bit cameraserver"
* changes:
Camera: Enable 64-bit cameraserver builds
Camera: Update ZSL result container
diff --git a/OWNERS b/OWNERS
index 8f405e9..9989bf0 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,3 +2,7 @@
etalvala@google.com
lajos@google.com
marcone@google.com
+
+# LON
+olly@google.com
+andrewlewis@google.com
diff --git a/media/libaaudio/include/aaudio/AAudio.h b/media/libaaudio/include/aaudio/AAudio.h
index eeba10c..ea4fe04 100644
--- a/media/libaaudio/include/aaudio/AAudio.h
+++ b/media/libaaudio/include/aaudio/AAudio.h
@@ -920,8 +920,9 @@
* It will stop being called after AAudioStream_requestPause() or
* AAudioStream_requestStop() is called.
*
- * This callback function will be called on a real-time thread owned by AAudio. See
- * {@link #AAudioStream_dataCallback} for more information.
+ * This callback function will be called on a real-time thread owned by AAudio.
+ * The low latency streams may have callback threads with higher priority than normal streams.
+ * See {@link #AAudioStream_dataCallback} for more information.
*
* Note that the AAudio callbacks will never be called simultaneously from multiple threads.
*
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index adb16d4..771cfd9 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -24,7 +24,7 @@
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
-#include <media/AudioSanitizer.h>
+#include <media/AudioValidator.h>
#include <media/IAudioPolicyService.h>
#include <mediautils/ServiceUtilities.h>
#include <mediautils/TimeCheck.h>
@@ -1651,7 +1651,7 @@
ALOGE("b/23905951");
return status;
}
- status = AudioSanitizer::sanitizeAudioPort(&port);
+ status = AudioValidator::validateAudioPort(port);
if (status == NO_ERROR) {
status = getAudioPort(&port);
}
@@ -1674,7 +1674,7 @@
ALOGE("b/23905951");
return status;
}
- status = AudioSanitizer::sanitizeAudioPatch(&patch);
+ status = AudioValidator::validateAudioPatch(patch);
if (status == NO_ERROR) {
status = createAudioPatch(&patch, &handle);
}
@@ -1726,7 +1726,7 @@
if (status != NO_ERROR) {
return status;
}
- status = AudioSanitizer::sanitizeAudioPortConfig(&config);
+ status = AudioValidator::validateAudioPortConfig(config);
if (status == NO_ERROR) {
status = setAudioPortConfig(&config);
}
diff --git a/media/libaudioclient/IAudioPolicyService.cpp b/media/libaudioclient/IAudioPolicyService.cpp
index cd098b5..4132244 100644
--- a/media/libaudioclient/IAudioPolicyService.cpp
+++ b/media/libaudioclient/IAudioPolicyService.cpp
@@ -26,7 +26,7 @@
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
#include <media/AudioEffect.h>
-#include <media/AudioSanitizer.h>
+#include <media/AudioValidator.h>
#include <media/IAudioPolicyService.h>
#include <mediautils/ServiceUtilities.h>
#include <mediautils/TimeCheck.h>
@@ -529,7 +529,11 @@
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
data.write(desc, sizeof(effect_descriptor_t));
- remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
+ status_t status = remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
+ if (status != NO_ERROR ||
+ (status = (status_t)reply.readInt32()) != NO_ERROR) {
+ return AUDIO_IO_HANDLE_NONE;
+ }
return static_cast <audio_io_handle_t> (reply.readInt32());
}
@@ -1779,13 +1783,15 @@
audio_io_handle_t output = 0;
std::vector<audio_io_handle_t> secondaryOutputs;
- status = AudioSanitizer::sanitizeAudioAttributes(&attr, "68953950");
- if (status == NO_ERROR) {
- status = getOutputForAttr(&attr,
- &output, session, &stream, pid, uid,
- &config,
- flags, &selectedDeviceId, &portId, &secondaryOutputs);
+ status = AudioValidator::validateAudioAttributes(attr, "68953950");
+ if (status != NO_ERROR) {
+ reply->writeInt32(status);
+ return NO_ERROR;
}
+ status = getOutputForAttr(&attr,
+ &output, session, &stream, pid, uid,
+ &config,
+ flags, &selectedDeviceId, &portId, &secondaryOutputs);
reply->writeInt32(status);
status = reply->write(&attr, sizeof(audio_attributes_t));
if (status != NO_ERROR) {
@@ -1842,7 +1848,7 @@
audio_port_handle_t selectedDeviceId = (audio_port_handle_t) data.readInt32();
audio_port_handle_t portId = (audio_port_handle_t)data.readInt32();
- status = AudioSanitizer::sanitizeAudioAttributes(&attr, "68953950");
+ status = AudioValidator::validateAudioAttributes(attr, "68953950");
if (status == NO_ERROR) {
status = getInputForAttr(&attr, &input, riid, session, pid, uid,
opPackageName, &config,
@@ -1932,7 +1938,7 @@
int index = data.readInt32();
audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "169572641");
+ status = AudioValidator::validateAudioAttributes(attributes, "169572641");
if (status == NO_ERROR) {
status = setVolumeIndexForAttributes(attributes, index, device);
}
@@ -1950,7 +1956,7 @@
audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
int index = 0;
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "169572641");
+ status = AudioValidator::validateAudioAttributes(attributes, "169572641");
if (status == NO_ERROR) {
status = getVolumeIndexForAttributes(attributes, index, device);
}
@@ -1970,7 +1976,7 @@
}
int index = 0;
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "169572641");
+ status = AudioValidator::validateAudioAttributes(attributes, "169572641");
if (status == NO_ERROR) {
status = getMinVolumeIndexForAttributes(attributes, index);
}
@@ -1990,7 +1996,7 @@
}
int index = 0;
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "169572641");
+ status = AudioValidator::validateAudioAttributes(attributes, "169572641");
if (status == NO_ERROR) {
status = getMaxVolumeIndexForAttributes(attributes, index);
}
@@ -2017,12 +2023,12 @@
android_errorWriteLog(0x534e4554, "73126106");
return status;
}
- audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
- status = AudioSanitizer::sanitizeEffectDescriptor(&desc, "73126106");
+ status = AudioValidator::validateEffectDescriptor(desc, "73126106");
+ reply->writeInt32(status);
if (status == NO_ERROR) {
- output = getOutputForEffect(&desc);
+ audio_io_handle_t output = getOutputForEffect(&desc);
+ reply->writeInt32(static_cast <int32_t>(output));
}
- reply->writeInt32(static_cast <int32_t>(output));
return NO_ERROR;
} break;
@@ -2038,7 +2044,7 @@
uint32_t strategy = data.readInt32();
audio_session_t session = (audio_session_t) data.readInt32();
int id = data.readInt32();
- status = AudioSanitizer::sanitizeEffectDescriptor(&desc, "73126106");
+ status = AudioValidator::validateEffectDescriptor(desc, "73126106");
if (status == NO_ERROR) {
status = registerEffect(&desc, io, strategy, session, id);
}
@@ -2151,7 +2157,7 @@
if (status != NO_ERROR) return status;
status = data.read(&attributes, sizeof(audio_attributes_t));
if (status != NO_ERROR) return status;
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "169572641");
+ status = AudioValidator::validateAudioAttributes(attributes, "169572641");
if (status == NO_ERROR) {
status = isDirectOutputSupported(config, attributes);
}
@@ -2199,7 +2205,7 @@
ALOGE("b/23912202");
return status;
}
- status = AudioSanitizer::sanitizeAudioPort(&port);
+ status = AudioValidator::validateAudioPort(port);
if (status == NO_ERROR) {
status = getAudioPort(&port);
}
@@ -2223,7 +2229,7 @@
ALOGE("b/23912202");
return status;
}
- status = AudioSanitizer::sanitizeAudioPatch(&patch);
+ status = AudioValidator::validateAudioPatch(patch);
if (status == NO_ERROR) {
status = createAudioPatch(&patch, &handle);
}
@@ -2280,8 +2286,10 @@
if (status != NO_ERROR) {
return status;
}
- (void)AudioSanitizer::sanitizeAudioPortConfig(&config);
- status = setAudioPortConfig(&config);
+ status = AudioValidator::validateAudioPortConfig(config);
+ if (status == NO_ERROR) {
+ status = setAudioPortConfig(&config);
+ }
reply->writeInt32(status);
return NO_ERROR;
}
@@ -2366,11 +2374,11 @@
if (status != NO_ERROR) {
return status;
}
- status = AudioSanitizer::sanitizeAudioPortConfig(&source);
+ status = AudioValidator::validateAudioPortConfig(source);
if (status == NO_ERROR) {
// OK to not always sanitize attributes as startAudioSource() is not called if
// the port config is invalid.
- status = AudioSanitizer::sanitizeAudioAttributes(&attributes, "68953950");
+ status = AudioValidator::validateAudioAttributes(attributes, "68953950");
}
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE;
if (status == NO_ERROR) {
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index f2f74a5..d8840b2 100644
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -775,7 +775,7 @@
#else
effect->session->config =
effect->session->apm->GetConfig() ;
- effect->session->config.echo_canceller.mobile_mode = false;
+ effect->session->config.echo_canceller.mobile_mode = true;
effect->session->apm->ApplyConfig(effect->session->config);
#endif
return 0;
diff --git a/media/libeffects/preprocessing/benchmarks/Android.bp b/media/libeffects/preprocessing/benchmarks/Android.bp
new file mode 100644
index 0000000..2808293
--- /dev/null
+++ b/media/libeffects/preprocessing/benchmarks/Android.bp
@@ -0,0 +1,51 @@
+cc_benchmark {
+ name: "preprocessing_legacy_benchmark",
+ vendor: true,
+ relative_install_path: "soundfx",
+ srcs: ["preprocessing_benchmark.cpp"],
+ shared_libs: [
+ "libaudiopreprocessing_legacy",
+ "libaudioutils",
+ "liblog",
+ "libutils",
+ "libwebrtc_audio_preprocessing",
+ ],
+ cflags: [
+ "-DWEBRTC_POSIX",
+ "-DWEBRTC_LEGACY",
+ "-fvisibility=default",
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ header_libs: [
+ "libaudioeffects",
+ "libhardware_headers",
+ "libwebrtc_absl_headers",
+ ],
+}
+
+cc_benchmark {
+ name: "preprocessing_benchmark",
+ vendor: true,
+ relative_install_path: "soundfx",
+ srcs: ["preprocessing_benchmark.cpp"],
+ shared_libs: [
+ "libaudiopreprocessing",
+ "libaudioutils",
+ "liblog",
+ "libutils",
+ ],
+ cflags: [
+ "-DWEBRTC_POSIX",
+ "-fvisibility=default",
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ header_libs: [
+ "libaudioeffects",
+ "libhardware_headers",
+ "libwebrtc_absl_headers",
+ ],
+}
diff --git a/media/libeffects/preprocessing/benchmarks/preprocessing_benchmark.cpp b/media/libeffects/preprocessing/benchmarks/preprocessing_benchmark.cpp
new file mode 100644
index 0000000..d4df371
--- /dev/null
+++ b/media/libeffects/preprocessing/benchmarks/preprocessing_benchmark.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2020 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.
+ */
+
+/*******************************************************************
+ * A test result running on Pixel 3 for comparison.
+ * The first parameter indicates the channel mask index.
+ * The second parameter indicates the effect index.
+ * 0: Automatic Gain Control,
+ * 1: Acoustic Echo Canceler,
+ * 2: Noise Suppressor,
+ * 3: Automatic Gain Control 2
+ * ---------------------------------------------------------------
+ * Benchmark Time CPU Iterations
+ * ---------------------------------------------------------------
+ * BM_PREPROCESSING/1/0 59836 ns 59655 ns 11732
+ * BM_PREPROCESSING/1/1 66848 ns 66642 ns 10554
+ * BM_PREPROCESSING/1/2 20726 ns 20655 ns 33822
+ * BM_PREPROCESSING/1/3 5093 ns 5076 ns 137897
+ * BM_PREPROCESSING/2/0 117040 ns 116670 ns 5996
+ * BM_PREPROCESSING/2/1 120600 ns 120225 ns 5845
+ * BM_PREPROCESSING/2/2 38460 ns 38330 ns 18190
+ * BM_PREPROCESSING/2/3 6294 ns 6274 ns 111488
+ * BM_PREPROCESSING/3/0 232272 ns 231528 ns 3025
+ * BM_PREPROCESSING/3/1 226346 ns 225628 ns 3117
+ * BM_PREPROCESSING/3/2 75442 ns 75227 ns 9104
+ * BM_PREPROCESSING/3/3 9782 ns 9750 ns 71805
+ * BM_PREPROCESSING/4/0 290388 ns 289426 ns 2389
+ * BM_PREPROCESSING/4/1 279394 ns 278498 ns 2522
+ * BM_PREPROCESSING/4/2 94029 ns 93759 ns 7307
+ * BM_PREPROCESSING/4/3 11487 ns 11450 ns 61129
+ * BM_PREPROCESSING/5/0 347736 ns 346580 ns 2020
+ * BM_PREPROCESSING/5/1 331853 ns 330788 ns 2122
+ * BM_PREPROCESSING/5/2 112594 ns 112268 ns 6105
+ * BM_PREPROCESSING/5/3 13254 ns 13212 ns 52972
+ *******************************************************************/
+
+#include <array>
+#include <climits>
+#include <cstdlib>
+#include <random>
+#include <vector>
+#include <audio_effects/effect_aec.h>
+#include <audio_effects/effect_agc.h>
+#ifndef WEBRTC_LEGACY
+#include <audio_effects/effect_agc2.h>
+#endif
+#include <audio_effects/effect_ns.h>
+#include <benchmark/benchmark.h>
+#include <hardware/audio_effect.h>
+#include <log/log.h>
+#include <sys/stat.h>
+#include <system/audio.h>
+
+extern audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM;
+
+constexpr int kSampleRate = 16000;
+constexpr float kTenMilliSecVal = 0.01;
+constexpr unsigned int kStreamDelayMs = 0;
+constexpr effect_uuid_t kEffectUuids[] = {
+ // agc uuid
+ {0xaa8130e0, 0x66fc, 0x11e0, 0xbad0, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
+ // aec uuid
+ {0xbb392ec0, 0x8d4d, 0x11e0, 0xa896, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
+ // ns uuid
+ {0xc06c8400, 0x8e06, 0x11e0, 0x9cb6, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
+#ifndef WEBRTC_LEGACY
+ // agc2 uuid
+ {0x89f38e65, 0xd4d2, 0x4d64, 0xad0e, {0x2b, 0x3e, 0x79, 0x9e, 0xa8, 0x86}},
+#endif
+};
+constexpr size_t kNumEffectUuids = std::size(kEffectUuids);
+constexpr audio_channel_mask_t kChMasks[] = {
+ AUDIO_CHANNEL_IN_MONO,
+ AUDIO_CHANNEL_IN_STEREO,
+ AUDIO_CHANNEL_IN_2POINT0POINT2,
+ AUDIO_CHANNEL_IN_2POINT1POINT2,
+ AUDIO_CHANNEL_IN_6,
+};
+constexpr size_t kNumChMasks = std::size(kChMasks);
+
+// types of pre processing modules
+enum PreProcId {
+ PREPROC_AGC, // Automatic Gain Control
+ PREPROC_AEC, // Acoustic Echo Canceler
+ PREPROC_NS, // Noise Suppressor
+#ifndef WEBRTC_LEGACY
+ PREPROC_AGC2, // Automatic Gain Control 2
+#endif
+ PREPROC_NUM_EFFECTS
+};
+
+int preProcCreateEffect(effect_handle_t *pEffectHandle, uint32_t effectType,
+ effect_config_t *pConfig, int sessionId, int ioId) {
+ if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.create_effect(
+ &kEffectUuids[effectType], sessionId, ioId, pEffectHandle);
+ status != 0) {
+ ALOGE("Audio Preprocessing create returned an error = %d\n", status);
+ return EXIT_FAILURE;
+ }
+ int reply = 0;
+ uint32_t replySize = sizeof(reply);
+ if (effectType == PREPROC_AEC) {
+ if (int status =
+ (**pEffectHandle)
+ ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG_REVERSE,
+ sizeof(effect_config_t), pConfig, &replySize, &reply);
+ status != 0) {
+ ALOGE("Set config reverse command returned an error = %d\n", status);
+ return EXIT_FAILURE;
+ }
+ }
+ if (int status =
+ (**pEffectHandle)
+ ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG,
+ sizeof(effect_config_t), pConfig, &replySize, &reply);
+ status != 0) {
+ ALOGE("Set config command returned an error = %d\n", status);
+ return EXIT_FAILURE;
+ }
+ return reply;
+}
+
+int preProcSetConfigParam(effect_handle_t effectHandle, uint32_t paramType,
+ uint32_t paramValue) {
+ int reply = 0;
+ uint32_t replySize = sizeof(reply);
+ uint32_t paramData[2] = {paramType, paramValue};
+ effect_param_t *effectParam =
+ (effect_param_t *)malloc(sizeof(*effectParam) + sizeof(paramData));
+ memcpy(&effectParam->data[0], ¶mData[0], sizeof(paramData));
+ effectParam->psize = sizeof(paramData[0]);
+ (*effectHandle)
+ ->command(effectHandle, EFFECT_CMD_SET_PARAM, sizeof(effect_param_t),
+ effectParam, &replySize, &reply);
+ free(effectParam);
+ return reply;
+}
+
+short preProcGetShortVal(float paramValue) {
+ return static_cast<short>(paramValue * std::numeric_limits<short>::max());
+}
+
+static void BM_PREPROCESSING(benchmark::State &state) {
+ const size_t chMask = kChMasks[state.range(0) - 1];
+ const size_t channelCount = audio_channel_count_from_in_mask(chMask);
+
+ PreProcId effectType = (PreProcId)state.range(1);
+
+ int32_t sessionId = 1;
+ int32_t ioId = 1;
+ effect_handle_t effectHandle = nullptr;
+ effect_config_t config{};
+ config.inputCfg.samplingRate = config.outputCfg.samplingRate = kSampleRate;
+ config.inputCfg.channels = config.outputCfg.channels = chMask;
+ config.inputCfg.format = config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+
+ if (int status = preProcCreateEffect(&effectHandle, state.range(1), &config,
+ sessionId, ioId);
+ status != 0) {
+ ALOGE("Create effect call returned error %i", status);
+ return;
+ }
+
+ int reply = 0;
+ uint32_t replySize = sizeof(reply);
+ if (int status = (*effectHandle)
+ ->command(effectHandle, EFFECT_CMD_ENABLE, 0, nullptr,
+ &replySize, &reply);
+ status != 0) {
+ ALOGE("Command enable call returned error %d\n", reply);
+ return;
+ }
+
+ // Initialize input buffer with deterministic pseudo-random values
+ const int frameLength = (int)(kSampleRate * kTenMilliSecVal);
+ std::minstd_rand gen(chMask);
+ std::uniform_real_distribution<> dis(-1.0f, 1.0f);
+ std::vector<short> in(frameLength * channelCount);
+ for (auto &i : in) {
+ i = preProcGetShortVal(dis(gen));
+ }
+ std::vector<short> farIn(frameLength * channelCount);
+ for (auto &i : farIn) {
+ i = preProcGetShortVal(dis(gen));
+ }
+ std::vector<short> out(frameLength * channelCount);
+
+ // Run the test
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(in.data());
+ benchmark::DoNotOptimize(out.data());
+ benchmark::DoNotOptimize(farIn.data());
+
+ audio_buffer_t inBuffer = {.frameCount = (size_t)frameLength,
+ .s16 = in.data()};
+ audio_buffer_t outBuffer = {.frameCount = (size_t)frameLength,
+ .s16 = out.data()};
+ audio_buffer_t farInBuffer = {.frameCount = (size_t)frameLength,
+ .s16 = farIn.data()};
+
+ if (PREPROC_AEC == effectType) {
+ if (int status = preProcSetConfigParam(effectHandle, AEC_PARAM_ECHO_DELAY,
+ kStreamDelayMs);
+ status != 0) {
+ ALOGE("preProcSetConfigParam returned Error %d\n", status);
+ return;
+ }
+ }
+ if (int status =
+ (*effectHandle)->process(effectHandle, &inBuffer, &outBuffer);
+ status != 0) {
+ ALOGE("\nError: Process i = %d returned with error %d\n",
+ (int)state.range(1), status);
+ return;
+ }
+ if (PREPROC_AEC == effectType) {
+ if (int status =
+ (*effectHandle)
+ ->process_reverse(effectHandle, &farInBuffer, &outBuffer);
+ status != 0) {
+ ALOGE("\nError: Process reverse i = %d returned with error %d\n",
+ (int)state.range(1), status);
+ return;
+ }
+ }
+ }
+ benchmark::ClobberMemory();
+
+ state.SetComplexityN(state.range(0));
+
+ if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.release_effect(effectHandle);
+ status != 0) {
+ ALOGE("release_effect returned an error = %d\n", status);
+ return;
+ }
+}
+
+static void preprocessingArgs(benchmark::internal::Benchmark *b) {
+ for (int i = 1; i <= (int)kNumChMasks; i++) {
+ for (int j = 0; j < (int)kNumEffectUuids; ++j) {
+ b->Args({i, j});
+ }
+ }
+}
+
+BENCHMARK(BM_PREPROCESSING)->Apply(preprocessingArgs);
+
+BENCHMARK_MAIN();
diff --git a/media/libeffects/preprocessing/tests/PreProcessingTest.cpp b/media/libeffects/preprocessing/tests/PreProcessingTest.cpp
index 3244c1f..3e8ea76 100644
--- a/media/libeffects/preprocessing/tests/PreProcessingTest.cpp
+++ b/media/libeffects/preprocessing/tests/PreProcessingTest.cpp
@@ -58,7 +58,6 @@
ARG_AEC_DELAY,
ARG_NS_LVL,
#ifndef WEBRTC_LEGACY
- ARG_AEC_MOBILE,
ARG_AGC2_GAIN,
ARG_AGC2_LVL,
ARG_AGC2_SAT_MGN
@@ -159,10 +158,6 @@
#endif
printf("\n --aec_delay <delay>");
printf("\n AEC delay value in ms, default value 0ms");
-#ifndef WEBRTC_LEGACY
- printf("\n --aec_mobile");
- printf("\n Enable mobile mode of echo canceller, default disabled");
-#endif
printf("\n");
}
@@ -213,9 +208,6 @@
const char *outputFile = nullptr;
const char *farFile = nullptr;
int effectEn[PREPROC_NUM_EFFECTS] = {0};
-#ifndef WEBRTC_LEGACY
- int aecMobileMode = 0;
-#endif
const option long_opts[] = {
{"help", no_argument, nullptr, ARG_HELP},
@@ -239,9 +231,6 @@
{"agc2", no_argument, &effectEn[PREPROC_AGC2], 1},
#endif
{"ns", no_argument, &effectEn[PREPROC_NS], 1},
-#ifndef WEBRTC_LEGACY
- {"aec_mobile", no_argument, &aecMobileMode, 1},
-#endif
{nullptr, 0, nullptr, 0},
};
struct preProcConfigParams_t preProcCfgParams {};
@@ -432,16 +421,6 @@
return EXIT_FAILURE;
}
}
-#ifndef WEBRTC_LEGACY
- if (effectEn[PREPROC_AEC]) {
- if (int status = preProcSetConfigParam(AEC_PARAM_MOBILE_MODE, (uint32_t)aecMobileMode,
- effectHandle[PREPROC_AEC]);
- status != 0) {
- ALOGE("Invalid AEC mobile mode value %d\n", status);
- return EXIT_FAILURE;
- }
- }
-#endif
// Process Call
const int frameLength = (int)(preProcCfgParams.samplingFreq * kTenMilliSecVal);
diff --git a/media/libmediahelper/Android.bp b/media/libmediahelper/Android.bp
index 0779a8e..6c43fe0 100644
--- a/media/libmediahelper/Android.bp
+++ b/media/libmediahelper/Android.bp
@@ -20,7 +20,7 @@
double_loadable: true,
srcs: [
"AudioParameter.cpp",
- "AudioSanitizer.cpp",
+ "AudioValidator.cpp",
"TypeConverter.cpp",
],
cflags: [
diff --git a/media/libmediahelper/AudioSanitizer.cpp b/media/libmediahelper/AudioSanitizer.cpp
deleted file mode 100644
index 9223823..0000000
--- a/media/libmediahelper/AudioSanitizer.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2020 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 <media/AudioSanitizer.h>
-
-namespace android {
-
- /** returns true if string overflow was prevented by zero termination */
-template <size_t size>
-bool preventStringOverflow(char (&s)[size]) {
- if (strnlen(s, size) < size) return false;
- s[size - 1] = '\0';
- return true;
-}
-
-status_t safetyNetLog(status_t status, const char *bugNumber) {
- if (status != NO_ERROR && bugNumber != nullptr) {
- android_errorWriteLog(0x534e4554, bugNumber); // SafetyNet logging
- }
- return status;
-}
-
-status_t AudioSanitizer::sanitizeAudioAttributes(
- audio_attributes_t *attr, const char *bugNumber)
-{
- status_t status = NO_ERROR;
- const size_t tagsMaxSize = AUDIO_ATTRIBUTES_TAGS_MAX_SIZE;
- if (strnlen(attr->tags, tagsMaxSize) >= tagsMaxSize) {
- status = BAD_VALUE;
- }
- attr->tags[tagsMaxSize - 1] = '\0';
- return safetyNetLog(status, bugNumber);
-}
-
-/** returns BAD_VALUE if sanitization was required. */
-status_t AudioSanitizer::sanitizeEffectDescriptor(
- effect_descriptor_t *desc, const char *bugNumber)
-{
- status_t status = NO_ERROR;
- if (preventStringOverflow(desc->name)
- | /* always */ preventStringOverflow(desc->implementor)) {
- status = BAD_VALUE;
- }
- return safetyNetLog(status, bugNumber);
-}
-
-/** returns BAD_VALUE if sanitization was required. */
-status_t AudioSanitizer::sanitizeAudioPortConfig(
- struct audio_port_config *config, const char *bugNumber)
-{
- status_t status = NO_ERROR;
- if (config->type == AUDIO_PORT_TYPE_DEVICE &&
- preventStringOverflow(config->ext.device.address)) {
- status = BAD_VALUE;
- }
- return safetyNetLog(status, bugNumber);
-}
-
-namespace {
-
-template <typename T, std::enable_if_t<std::is_same<T, struct audio_port>::value
- || std::is_same<T, struct audio_port_v7>::value, int> = 0>
-static status_t sanitizeAudioPortInternal(T *port, const char *bugNumber = nullptr) {
- status_t status = NO_ERROR;
- if (preventStringOverflow(port->name)) {
- status = BAD_VALUE;
- }
- if (AudioSanitizer::sanitizeAudioPortConfig(&port->active_config) != NO_ERROR) {
- status = BAD_VALUE;
- }
- if (port->type == AUDIO_PORT_TYPE_DEVICE &&
- preventStringOverflow(port->ext.device.address)) {
- status = BAD_VALUE;
- }
- return safetyNetLog(status, bugNumber);
-}
-
-} // namespace
-
-/** returns BAD_VALUE if sanitization was required. */
-status_t AudioSanitizer::sanitizeAudioPort(
- struct audio_port *port, const char *bugNumber)
-{
- return sanitizeAudioPortInternal(port, bugNumber);
-}
-
-/** returns BAD_VALUE if sanitization was required. */
-status_t AudioSanitizer::sanitizeAudioPort(
- struct audio_port_v7 *port, const char *bugNumber)
-{
- return sanitizeAudioPortInternal(port, bugNumber);
-}
-
-/** returns BAD_VALUE if sanitization was required. */
-status_t AudioSanitizer::sanitizeAudioPatch(
- struct audio_patch *patch, const char *bugNumber)
-{
- status_t status = NO_ERROR;
- if (patch->num_sources > AUDIO_PATCH_PORTS_MAX) {
- patch->num_sources = AUDIO_PATCH_PORTS_MAX;
- status = BAD_VALUE;
- }
- if (patch->num_sinks > AUDIO_PATCH_PORTS_MAX) {
- patch->num_sinks = AUDIO_PATCH_PORTS_MAX;
- status = BAD_VALUE;
- }
- for (size_t i = 0; i < patch->num_sources; i++) {
- if (sanitizeAudioPortConfig(&patch->sources[i]) != NO_ERROR) {
- status = BAD_VALUE;
- }
- }
- for (size_t i = 0; i < patch->num_sinks; i++) {
- if (sanitizeAudioPortConfig(&patch->sinks[i]) != NO_ERROR) {
- status = BAD_VALUE;
- }
- }
- return safetyNetLog(status, bugNumber);
-}
-
-}; // namespace android
diff --git a/media/libmediahelper/AudioValidator.cpp b/media/libmediahelper/AudioValidator.cpp
new file mode 100644
index 0000000..e2fd8ae
--- /dev/null
+++ b/media/libmediahelper/AudioValidator.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2020 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 <media/AudioValidator.h>
+
+namespace android {
+
+/** returns true if string is overflow */
+template <size_t size>
+bool checkStringOverflow(const char (&s)[size]) {
+ return strnlen(s, size) >= size;
+}
+
+status_t safetyNetLog(status_t status, std::string_view bugNumber) {
+ if (status != NO_ERROR && !bugNumber.empty()) {
+ android_errorWriteLog(0x534e4554, bugNumber.data()); // SafetyNet logging
+ }
+ return status;
+}
+
+status_t AudioValidator::validateAudioAttributes(
+ const audio_attributes_t& attr, std::string_view bugNumber)
+{
+ status_t status = NO_ERROR;
+ const size_t tagsMaxSize = AUDIO_ATTRIBUTES_TAGS_MAX_SIZE;
+ if (strnlen(attr.tags, tagsMaxSize) >= tagsMaxSize) {
+ status = BAD_VALUE;
+ }
+ return safetyNetLog(status, bugNumber);
+}
+
+status_t AudioValidator::validateEffectDescriptor(
+ const effect_descriptor_t& desc, std::string_view bugNumber)
+{
+ status_t status = NO_ERROR;
+ if (checkStringOverflow(desc.name)
+ | /* always */ checkStringOverflow(desc.implementor)) {
+ status = BAD_VALUE;
+ }
+ return safetyNetLog(status, bugNumber);
+}
+
+status_t AudioValidator::validateAudioPortConfig(
+ const struct audio_port_config& config, std::string_view bugNumber)
+{
+ status_t status = NO_ERROR;
+ if (config.type == AUDIO_PORT_TYPE_DEVICE &&
+ checkStringOverflow(config.ext.device.address)) {
+ status = BAD_VALUE;
+ }
+ return safetyNetLog(status, bugNumber);
+}
+
+namespace {
+
+template <typename T, std::enable_if_t<std::is_same<T, struct audio_port>::value
+ || std::is_same<T, struct audio_port_v7>::value, int> = 0>
+static status_t validateAudioPortInternal(const T& port, std::string_view bugNumber = {}) {
+ status_t status = NO_ERROR;
+ if (checkStringOverflow(port.name)) {
+ status = BAD_VALUE;
+ }
+ if (AudioValidator::validateAudioPortConfig(port.active_config) != NO_ERROR) {
+ status = BAD_VALUE;
+ }
+ if (port.type == AUDIO_PORT_TYPE_DEVICE &&
+ checkStringOverflow(port.ext.device.address)) {
+ status = BAD_VALUE;
+ }
+ return safetyNetLog(status, bugNumber);
+}
+
+} // namespace
+
+status_t AudioValidator::validateAudioPort(
+ const struct audio_port& port, std::string_view bugNumber)
+{
+ return validateAudioPortInternal(port, bugNumber);
+}
+
+status_t AudioValidator::validateAudioPort(
+ const struct audio_port_v7& port, std::string_view bugNumber)
+{
+ return validateAudioPortInternal(port, bugNumber);
+}
+
+/** returns BAD_VALUE if sanitization was required. */
+status_t AudioValidator::validateAudioPatch(
+ const struct audio_patch& patch, std::string_view bugNumber)
+{
+ status_t status = NO_ERROR;
+ if (patch.num_sources > AUDIO_PATCH_PORTS_MAX) {
+ status = BAD_VALUE;
+ }
+ if (patch.num_sinks > AUDIO_PATCH_PORTS_MAX) {
+ status = BAD_VALUE;
+ }
+ for (size_t i = 0; i < patch.num_sources; i++) {
+ if (validateAudioPortConfig(patch.sources[i]) != NO_ERROR) {
+ status = BAD_VALUE;
+ }
+ }
+ for (size_t i = 0; i < patch.num_sinks; i++) {
+ if (validateAudioPortConfig(patch.sinks[i]) != NO_ERROR) {
+ status = BAD_VALUE;
+ }
+ }
+ return safetyNetLog(status, bugNumber);
+}
+
+}; // namespace android
diff --git a/media/libmediahelper/include/media/AudioSanitizer.h b/media/libmediahelper/include/media/AudioSanitizer.h
deleted file mode 100644
index 84bcb62..0000000
--- a/media/libmediahelper/include/media/AudioSanitizer.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-#ifndef ANDROID_AUDIO_SANITIZER_H_
-#define ANDROID_AUDIO_SANITIZER_H_
-
-#include <system/audio.h>
-#include <system/audio_effect.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-namespace android {
-
-class AudioSanitizer {
-public:
- static status_t sanitizeAudioAttributes(
- audio_attributes_t *attr, const char *bugNumber = nullptr);
-
- static status_t sanitizeEffectDescriptor(
- effect_descriptor_t *desc, const char *bugNumber = nullptr);
-
- static status_t sanitizeAudioPortConfig(
- struct audio_port_config *config, const char *bugNumber = nullptr);
-
- static status_t sanitizeAudioPort(
- struct audio_port *port, const char *bugNumber = nullptr);
-
- static status_t sanitizeAudioPort(
- struct audio_port_v7 *port, const char *bugNumber = nullptr);
-
- static status_t sanitizeAudioPatch(
- struct audio_patch *patch, const char *bugNumber = nullptr);
-};
-
-}; // namespace android
-
-#endif /*ANDROID_AUDIO_SANITIZER_H_*/
diff --git a/media/libmediahelper/include/media/AudioValidator.h b/media/libmediahelper/include/media/AudioValidator.h
new file mode 100644
index 0000000..008868e
--- /dev/null
+++ b/media/libmediahelper/include/media/AudioValidator.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#ifndef ANDROID_AUDIO_VALIDATOR_H_
+#define ANDROID_AUDIO_VALIDATOR_H_
+
+#include <system/audio.h>
+#include <system/audio_effect.h>
+#include <utils/Errors.h>
+#include <utils/Log.h>
+
+#include <string_view>
+
+namespace android {
+
+/**
+ * AudioValidator is a class to validate audio data in binder call. NO_ERROR will be returned only
+ * when there is no error with the data.
+ */
+class AudioValidator {
+public:
+ /**
+ * Return NO_ERROR only when there is no error with the given audio attributes.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateAudioAttributes(
+ const audio_attributes_t& attr, std::string_view bugNumber = {});
+
+ /**
+ * Return NO_ERROR only when there is no error with the given effect descriptor.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateEffectDescriptor(
+ const effect_descriptor_t& desc, std::string_view bugNumber = {});
+
+ /**
+ * Return NO_ERROR only when there is no error with the given audio port config.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateAudioPortConfig(
+ const struct audio_port_config& config, std::string_view bugNumber = {});
+
+ /**
+ * Return NO_ERROR only when there is no error with the given audio port.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateAudioPort(
+ const struct audio_port& port, std::string_view bugNumber = {});
+
+ /**
+ * Return NO_ERROR only when there is no error with the given audio_port_v7.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateAudioPort(
+ const struct audio_port_v7& port, std::string_view ugNumber = {});
+
+ /**
+ * Return NO_ERROR only when there is no error with the given audio patch.
+ * Otherwise, return BAD_VALUE.
+ */
+ static status_t validateAudioPatch(
+ const struct audio_patch& patch, std::string_view bugNumber = {});
+};
+
+}; // namespace android
+
+#endif /*ANDROID_AUDIO_VALIDATOR_H_*/
diff --git a/services/mediametrics/statsd_audiopolicy.cpp b/services/mediametrics/statsd_audiopolicy.cpp
index 393c6ae..6ef2f2c 100644
--- a/services/mediametrics/statsd_audiopolicy.cpp
+++ b/services/mediametrics/statsd_audiopolicy.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_audiorecord.cpp b/services/mediametrics/statsd_audiorecord.cpp
index 43feda1..76f4b59 100644
--- a/services/mediametrics/statsd_audiorecord.cpp
+++ b/services/mediametrics/statsd_audiorecord.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_audiothread.cpp b/services/mediametrics/statsd_audiothread.cpp
index e867f5b..2ad2562 100644
--- a/services/mediametrics/statsd_audiothread.cpp
+++ b/services/mediametrics/statsd_audiothread.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_audiotrack.cpp b/services/mediametrics/statsd_audiotrack.cpp
index ee5b9b2..6b08a78 100644
--- a/services/mediametrics/statsd_audiotrack.cpp
+++ b/services/mediametrics/statsd_audiotrack.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_codec.cpp b/services/mediametrics/statsd_codec.cpp
index ec9354f..d502b30 100644
--- a/services/mediametrics/statsd_codec.cpp
+++ b/services/mediametrics/statsd_codec.cpp
@@ -33,7 +33,7 @@
#include "cleaner.h"
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_extractor.cpp b/services/mediametrics/statsd_extractor.cpp
index 3d5739f..16814d9 100644
--- a/services/mediametrics/statsd_extractor.cpp
+++ b/services/mediametrics/statsd_extractor.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_mediaparser.cpp b/services/mediametrics/statsd_mediaparser.cpp
index 3258ebf..262b2ae 100644
--- a/services/mediametrics/statsd_mediaparser.cpp
+++ b/services/mediametrics/statsd_mediaparser.cpp
@@ -31,7 +31,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_nuplayer.cpp b/services/mediametrics/statsd_nuplayer.cpp
index 488bdcb..a8d0f55 100644
--- a/services/mediametrics/statsd_nuplayer.cpp
+++ b/services/mediametrics/statsd_nuplayer.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {
diff --git a/services/mediametrics/statsd_recorder.cpp b/services/mediametrics/statsd_recorder.cpp
index 6d5fca0..2e5ada4 100644
--- a/services/mediametrics/statsd_recorder.cpp
+++ b/services/mediametrics/statsd_recorder.cpp
@@ -32,7 +32,7 @@
#include <statslog.h>
#include "MediaMetricsService.h"
-#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
+#include "frameworks/proto_logging/stats/enums/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
namespace android {