Code clean for audioflinger
Cleaning compile warnings:
1. For "variable 'XX' set but not used":
Remove the variables which are obviously not used;
Add "[[maybe_unused]]" to variable declaration of the ones
which are potentially used.
2. For "unused parameter 'XX'":
Add "[[maybe_unused]]" to the unused function parameters.
Test: mmm frameworks/av/services/audioflinger, presubmit check.
Change-Id: I6bd6fa9a57de93f5387e1ad76342f0a0b0ac28ed
Signed-off-by: Jing Mike <jingyangliu@eswincomputing.com>
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index c05aac1..ba7c6b6 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -4585,12 +4585,9 @@
// ----------------------------------------------------------------------------
status_t AudioFlinger::onTransactWrapper(TransactionCode code,
- const Parcel& data,
- uint32_t flags,
+ [[maybe_unused]] const Parcel& data,
+ [[maybe_unused]] uint32_t flags,
const std::function<status_t()>& delegate) {
- (void) data;
- (void) flags;
-
// make sure transactions reserved to AudioPolicyManager do not come from other processes
switch (code) {
case TransactionCode::SET_STREAM_VOLUME:
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 26bd92d..61dd3f2 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -79,8 +79,6 @@
mMasterMono(false),
mThreadIoHandle(parentIoHandle)
{
- (void)mThreadIoHandle; // prevent unused warning, see C++17 [[maybe_unused]]
-
// FIXME pass sInitial as parameter to base class constructor, and make it static local
mPrevious = &sInitial;
mCurrent = &sInitial;
diff --git a/services/audioflinger/FastMixer.h b/services/audioflinger/FastMixer.h
index 97ab635..d71519f 100644
--- a/services/audioflinger/FastMixer.h
+++ b/services/audioflinger/FastMixer.h
@@ -107,7 +107,8 @@
std::atomic<float> mMasterBalance{};
std::atomic_int_fast64_t mBoottimeOffset;
- const audio_io_handle_t mThreadIoHandle; // parent thread id for debugging purposes
+ // parent thread id for debugging purposes
+ [[maybe_unused]] const audio_io_handle_t mThreadIoHandle;
#ifdef TEE_SINK
NBAIO_Tee mTee;
#endif
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index b72348a..37b8fe8 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3293,7 +3293,7 @@
}
void AudioFlinger::PlaybackThread::threadLoop_removeTracks(
- const Vector< sp<Track> >& tracksToRemove)
+ [[maybe_unused]] const Vector< sp<Track> >& tracksToRemove)
{
// Miscellaneous track cleanup when removed from the active list,
// called without Thread lock but synchronized with threadLoop processing.
@@ -3304,8 +3304,6 @@
addBatteryData(IMediaPlayerService::kBatteryDataAudioFlingerStop);
}
}
-#else
- (void)tracksToRemove; // suppress unused warning
#endif
}
@@ -5829,7 +5827,7 @@
}
// Push the new FastMixer state if necessary
- bool pauseAudioWatchdog = false;
+ [[maybe_unused]] bool pauseAudioWatchdog = false;
if (didModify) {
state->mFastTracksGen++;
// if the fast mixer was active, but now there are no fast tracks, then put it in cold idle
@@ -7570,7 +7568,7 @@
size_t numCounterOffers = 0;
const NBAIO_Format offers[1] = {Format_from_SR_C(mSampleRate, mChannelCount, mFormat)};
#if !LOG_NDEBUG
- ssize_t index =
+ [[maybe_unused]] ssize_t index =
#else
(void)
#endif
@@ -7621,7 +7619,7 @@
Pipe *pipe = new Pipe(pipeFramesP2, format, pipeBuffer);
const NBAIO_Format offers[1] = {format};
size_t numCounterOffers = 0;
- ssize_t index = pipe->negotiate(offers, 1, NULL, numCounterOffers);
+ [[maybe_unused]] ssize_t index = pipe->negotiate(offers, 1, NULL, numCounterOffers);
ALOG_ASSERT(index == 0);
mPipeSink = pipe;
PipeReader *pipeReader = new PipeReader(*pipe);
@@ -9077,7 +9075,8 @@
audio_format_t reqFormat = mFormat;
uint32_t samplingRate = mSampleRate;
// TODO this may change if we want to support capture from HDMI PCM multi channel (e.g on TVs).
- audio_channel_mask_t channelMask = audio_channel_in_mask_from_count(mChannelCount);
+ [[maybe_unused]] audio_channel_mask_t channelMask =
+ audio_channel_in_mask_from_count(mChannelCount);
AudioParameter param = AudioParameter(keyValuePair);
int value;