Fix clang-tidy warnings in audio and playerservice.
* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1
Change-Id: I265f3b094e08d5705b506b3fbba51439c134af84
Merged-In: I265f3b094e08d5705b506b3fbba51439c134af84
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index b85b649..1f3f503 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1965,7 +1965,7 @@
return NO_ERROR;
}
-void AudioFlinger::closeOutputFinish(sp<PlaybackThread> thread)
+void AudioFlinger::closeOutputFinish(const sp<PlaybackThread>& thread)
{
AudioStreamOut *out = thread->clearOutput();
ALOG_ASSERT(out != NULL, "out shouldn't be NULL");
@@ -1974,7 +1974,7 @@
delete out;
}
-void AudioFlinger::closeOutputInternal_l(sp<PlaybackThread> thread)
+void AudioFlinger::closeOutputInternal_l(const sp<PlaybackThread>& thread)
{
mPlaybackThreads.removeItem(thread->mId);
thread->exit();
@@ -2225,7 +2225,7 @@
return NO_ERROR;
}
-void AudioFlinger::closeInputFinish(sp<RecordThread> thread)
+void AudioFlinger::closeInputFinish(const sp<RecordThread>& thread)
{
thread->exit();
AudioStreamIn *in = thread->clearInput();
@@ -2235,7 +2235,7 @@
delete in;
}
-void AudioFlinger::closeInputInternal_l(sp<RecordThread> thread)
+void AudioFlinger::closeInputInternal_l(const sp<RecordThread>& thread)
{
mRecordThreads.removeItem(thread->mId);
closeInputFinish(thread);
@@ -2433,7 +2433,7 @@
int triggerSession,
int listenerSession,
sync_event_callback_t callBack,
- wp<RefBase> cookie)
+ const wp<RefBase>& cookie)
{
Mutex::Autolock _l(mLock);
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 08fa70d..6848dea 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -323,7 +323,7 @@
int triggerSession,
int listenerSession,
sync_event_callback_t callBack,
- wp<RefBase> cookie);
+ const wp<RefBase>& cookie);
private:
@@ -496,7 +496,7 @@
// server side of the client's IAudioTrack
class TrackHandle : public android::BnAudioTrack {
public:
- TrackHandle(const sp<PlaybackThread::Track>& track);
+ explicit TrackHandle(const sp<PlaybackThread::Track>& track);
virtual ~TrackHandle();
virtual sp<IMemory> getCblk() const;
virtual status_t start();
@@ -524,7 +524,7 @@
// server side of the client's IAudioRecord
class RecordHandle : public android::BnAudioRecord {
public:
- RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
+ explicit RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
virtual ~RecordHandle();
virtual status_t start(int /*AudioSystem::sync_event_t*/ event, int triggerSession);
virtual void stop();
@@ -555,8 +555,8 @@
const String8& address,
audio_output_flags_t flags);
- void closeOutputFinish(sp<PlaybackThread> thread);
- void closeInputFinish(sp<RecordThread> thread);
+ void closeOutputFinish(const sp<PlaybackThread>& thread);
+ void closeInputFinish(const sp<RecordThread>& thread);
// no range check, AudioFlinger::mLock held
bool streamMute_l(audio_stream_type_t stream) const
@@ -720,9 +720,9 @@
// for use from destructor
status_t closeOutput_nonvirtual(audio_io_handle_t output);
- void closeOutputInternal_l(sp<PlaybackThread> thread);
+ void closeOutputInternal_l(const sp<PlaybackThread>& thread);
status_t closeInput_nonvirtual(audio_io_handle_t input);
- void closeInputInternal_l(sp<RecordThread> thread);
+ void closeInputInternal_l(const sp<RecordThread>& thread);
void setAudioHwSyncForSession_l(PlaybackThread *thread, audio_session_t sessionId);
status_t checkStreamType(audio_stream_type_t stream) const;
diff --git a/services/audioflinger/AudioWatchdog.h b/services/audioflinger/AudioWatchdog.h
index 4657530..7b69fc6 100644
--- a/services/audioflinger/AudioWatchdog.h
+++ b/services/audioflinger/AudioWatchdog.h
@@ -41,7 +41,7 @@
class AudioWatchdog : public Thread {
public:
- AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/), mPaused(false),
+ explicit AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/), mPaused(false),
mPeriodNs(periodMs * 1000000), mMaxCycleNs(mPeriodNs * 2),
// mOldTs
// mLogTs initialized below
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 949c91d..9d83a7b 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -1416,7 +1416,7 @@
}
// Must be called with EffectChain::mLock locked
-void AudioFlinger::EffectChain::clearInputBuffer_l(sp<ThreadBase> thread)
+void AudioFlinger::EffectChain::clearInputBuffer_l(const sp<ThreadBase>& thread)
{
// TODO: This will change in the future, depending on multichannel
// and sample format changes for effects.
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 6f93f81..28b70d7 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -355,7 +355,7 @@
// types or implementations from the suspend/restore mechanism.
bool isEffectEligibleForSuspend(const effect_descriptor_t& desc);
- void clearInputBuffer_l(sp<ThreadBase> thread);
+ void clearInputBuffer_l(const sp<ThreadBase>& thread);
void setThread(const sp<ThreadBase>& thread);
diff --git a/services/audioflinger/PatchPanel.h b/services/audioflinger/PatchPanel.h
index e31179c..a56932c 100644
--- a/services/audioflinger/PatchPanel.h
+++ b/services/audioflinger/PatchPanel.h
@@ -24,7 +24,7 @@
class Patch;
- PatchPanel(const sp<AudioFlinger>& audioFlinger);
+ explicit PatchPanel(const sp<AudioFlinger>& audioFlinger);
virtual ~PatchPanel();
/* List connected audio ports and their attributes */
@@ -54,7 +54,7 @@
class Patch {
public:
- Patch(const struct audio_patch *patch) :
+ explicit Patch(const struct audio_patch *patch) :
mAudioPatch(*patch), mHandle(AUDIO_PATCH_HANDLE_NONE),
mHalHandle(AUDIO_PATCH_HANDLE_NONE), mRecordPatchHandle(AUDIO_PATCH_HANDLE_NONE),
mPlaybackPatchHandle(AUDIO_PATCH_HANDLE_NONE) {}
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 66ebcda..30fa072 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1025,7 +1025,7 @@
mSuspendedSessions.valueAt(index);
for (size_t i = 0; i < sessionEffects.size(); i++) {
- sp<SuspendedSessionDesc> desc = sessionEffects.valueAt(i);
+ const sp<SuspendedSessionDesc>& desc = sessionEffects.valueAt(i);
for (int j = 0; j < desc->mRefCount; j++) {
if (sessionEffects.keyAt(i) == EffectChain::kKeyForSuspendAll) {
chain->setEffectSuspendedAll_l(true);
@@ -2666,14 +2666,14 @@
}
status_t AudioFlinger::PlaybackThread::attachAuxEffect(
- const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+ const sp<AudioFlinger::PlaybackThread::Track>& track, int EffectId)
{
Mutex::Autolock _l(mLock);
return attachAuxEffect_l(track, EffectId);
}
status_t AudioFlinger::PlaybackThread::attachAuxEffect_l(
- const sp<AudioFlinger::PlaybackThread::Track> track, int EffectId)
+ const sp<AudioFlinger::PlaybackThread::Track>& track, int EffectId)
{
status_t status = NO_ERROR;
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 46ac300..fed9582 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -97,7 +97,7 @@
sp<ConfigEventData> mData; // event specific parameter data
protected:
- ConfigEvent(int type, bool requiresSystemReady = false) :
+ explicit ConfigEvent(int type, bool requiresSystemReady = false) :
mType(type), mStatus(NO_ERROR), mWaitStatus(false),
mRequiresSystemReady(requiresSystemReady), mData(NULL) {}
};
@@ -149,7 +149,7 @@
class SetParameterConfigEventData : public ConfigEventData {
public:
- SetParameterConfigEventData(String8 keyValuePairs) :
+ explicit SetParameterConfigEventData(String8 keyValuePairs) :
mKeyValuePairs(keyValuePairs) {}
virtual void dump(char *buffer, size_t size) {
@@ -161,7 +161,7 @@
class SetParameterConfigEvent : public ConfigEvent {
public:
- SetParameterConfigEvent(String8 keyValuePairs) :
+ explicit SetParameterConfigEvent(String8 keyValuePairs) :
ConfigEvent(CFG_EVENT_SET_PARAMETER) {
mData = new SetParameterConfigEventData(keyValuePairs);
mWaitStatus = true;
@@ -196,7 +196,7 @@
class ReleaseAudioPatchConfigEventData : public ConfigEventData {
public:
- ReleaseAudioPatchConfigEventData(const audio_patch_handle_t handle) :
+ explicit ReleaseAudioPatchConfigEventData(const audio_patch_handle_t handle) :
mHandle(handle) {}
virtual void dump(char *buffer, size_t size) {
@@ -208,7 +208,7 @@
class ReleaseAudioPatchConfigEvent : public ConfigEvent {
public:
- ReleaseAudioPatchConfigEvent(const audio_patch_handle_t handle) :
+ explicit ReleaseAudioPatchConfigEvent(const audio_patch_handle_t handle) :
ConfigEvent(CFG_EVENT_RELEASE_AUDIO_PATCH) {
mData = new ReleaseAudioPatchConfigEventData(handle);
mWaitStatus = true;
@@ -218,7 +218,7 @@
class PMDeathRecipient : public IBinder::DeathRecipient {
public:
- PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
+ explicit PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
virtual ~PMDeathRecipient() {}
// IBinder::DeathRecipient
@@ -583,9 +583,9 @@
return reinterpret_cast<int16_t *>(mSinkBuffer); };
virtual void detachAuxEffect_l(int effectId);
- status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
+ status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track>& track,
int EffectId);
- status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
+ status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track>& track,
int EffectId);
virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
@@ -990,7 +990,7 @@
class AsyncCallbackThread : public Thread {
public:
- AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
+ explicit AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
virtual ~AsyncCallbackThread();
@@ -1073,7 +1073,7 @@
class ResamplerBufferProvider : public AudioBufferProvider
{
public:
- ResamplerBufferProvider(RecordTrack* recordTrack) :
+ explicit ResamplerBufferProvider(RecordTrack* recordTrack) :
mRecordTrack(recordTrack),
mRsmpInUnrel(0), mRsmpInFront(0) { }
virtual ~ResamplerBufferProvider() { }