Use -Werror in frameworks/av/media/libaaudio
* Remove unused local variables, labels, functions, private fields.
* Fix warning of unused return result.
* Use template functions in .h file to avoid warning of unused static functions.
Bug: 66996870
Test: build with WITH_TIDY=1
Exempt-From-Owner-Approval: cherry picked from goog
Merged-In: I54962a7fd36a405e54366130b9c0a24e26fe8ebb
Change-Id: I54962a7fd36a405e54366130b9c0a24e26fe8ebb
(cherry picked from commit 68326fe017a18957419a81489b67f75831f9a674)
diff --git a/media/libaaudio/tests/Android.bp b/media/libaaudio/tests/Android.bp
index 1c41cc6..05135df 100644
--- a/media/libaaudio/tests/Android.bp
+++ b/media/libaaudio/tests/Android.bp
@@ -1,11 +1,21 @@
+cc_defaults {
+ name: "libaaudio_tests_defaults",
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
+
cc_test {
name: "test_handle_tracker",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_handle_tracker.cpp"],
shared_libs: ["libaaudio"],
}
cc_test {
name: "test_aaudio_marshalling",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_marshalling.cpp"],
shared_libs: [
"libaaudio",
@@ -17,18 +27,21 @@
cc_test {
name: "test_block_adapter",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_block_adapter.cpp"],
shared_libs: ["libaaudio"],
}
cc_test {
name: "test_linear_ramp",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_linear_ramp.cpp"],
shared_libs: ["libaaudio"],
}
cc_test {
name: "test_open_params",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_open_params.cpp"],
shared_libs: [
"libaaudio",
@@ -40,6 +53,7 @@
cc_test {
name: "test_no_close",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_no_close.cpp"],
shared_libs: [
"libaaudio",
@@ -51,6 +65,7 @@
cc_test {
name: "test_aaudio_recovery",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_recovery.cpp"],
shared_libs: [
"libaaudio",
@@ -62,6 +77,7 @@
cc_test {
name: "test_n_streams",
+ defaults: ["libaaudio_tests_defaults"],
srcs: ["test_n_streams.cpp"],
shared_libs: [
"libaaudio",
diff --git a/media/libaaudio/tests/test_n_streams.cpp b/media/libaaudio/tests/test_n_streams.cpp
index 271d024..e2d4a82 100644
--- a/media/libaaudio/tests/test_n_streams.cpp
+++ b/media/libaaudio/tests/test_n_streams.cpp
@@ -71,7 +71,6 @@
AAudioStreamBuilder_delete(aaudioBuilder);
-finish:
return result;
}
diff --git a/media/libaaudio/tests/test_open_params.cpp b/media/libaaudio/tests/test_open_params.cpp
index 01b8799..3451242 100644
--- a/media/libaaudio/tests/test_open_params.cpp
+++ b/media/libaaudio/tests/test_open_params.cpp
@@ -25,21 +25,6 @@
#include <gtest/gtest.h>
-static const char *getSharingModeText(aaudio_sharing_mode_t mode) {
- const char *modeText = "unknown";
- switch (mode) {
- case AAUDIO_SHARING_MODE_EXCLUSIVE:
- modeText = "EXCLUSIVE";
- break;
- case AAUDIO_SHARING_MODE_SHARED:
- modeText = "SHARED";
- break;
- default:
- break;
- }
- return modeText;
-}
-
// Callback function that fills the audio output buffer.
aaudio_data_callback_result_t MyDataCallbackProc(
AAudioStream *stream,
@@ -67,7 +52,6 @@
int32_t actualChannelCount = 0;
int32_t actualSampleRate = 0;
aaudio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
- aaudio_sharing_mode_t actualSharingMode = AAUDIO_SHARING_MODE_SHARED;
aaudio_direction_t actualDirection;
AAudioStreamBuilder *aaudioBuilder = nullptr;
diff --git a/media/libaaudio/tests/test_recovery.cpp b/media/libaaudio/tests/test_recovery.cpp
index 7268a30..6e89f83 100644
--- a/media/libaaudio/tests/test_recovery.cpp
+++ b/media/libaaudio/tests/test_recovery.cpp
@@ -23,24 +23,9 @@
#define DEFAULT_TIMEOUT_NANOS ((int64_t)1000000000)
-static const char *getSharingModeText(aaudio_sharing_mode_t mode) {
- const char *modeText = "unknown";
- switch (mode) {
- case AAUDIO_SHARING_MODE_EXCLUSIVE:
- modeText = "EXCLUSIVE";
- break;
- case AAUDIO_SHARING_MODE_SHARED:
- modeText = "SHARED";
- break;
- default:
- break;
- }
- return modeText;
-}
-
int main(int argc, char **argv) {
(void) argc;
- (void *)argv;
+ (void) argv;
aaudio_result_t result = AAUDIO_OK;
@@ -52,7 +37,6 @@
int32_t actualChannelCount = 0;
int32_t actualSampleRate = 0;
aaudio_format_t actualDataFormat = AAUDIO_FORMAT_PCM_FLOAT;
- aaudio_sharing_mode_t actualSharingMode = AAUDIO_SHARING_MODE_SHARED;
AAudioStreamBuilder *aaudioBuilder = nullptr;
AAudioStream *aaudioStream = nullptr;