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
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 8866f5d..2d05a6d 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2022,7 +2022,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");
@@ -2031,7 +2031,7 @@
delete out;
}
-void AudioFlinger::closeOutputInternal_l(sp<PlaybackThread> thread)
+void AudioFlinger::closeOutputInternal_l(const sp<PlaybackThread>& thread)
{
mPlaybackThreads.removeItem(thread->mId);
thread->exit();
@@ -2292,7 +2292,7 @@
return NO_ERROR;
}
-void AudioFlinger::closeInputFinish(sp<RecordThread> thread)
+void AudioFlinger::closeInputFinish(const sp<RecordThread>& thread)
{
thread->exit();
AudioStreamIn *in = thread->clearInput();
@@ -2302,7 +2302,7 @@
delete in;
}
-void AudioFlinger::closeInputInternal_l(sp<RecordThread> thread)
+void AudioFlinger::closeInputInternal_l(const sp<RecordThread>& thread)
{
mRecordThreads.removeItem(thread->mId);
closeInputFinish(thread);
@@ -2558,7 +2558,7 @@
audio_session_t triggerSession,
audio_session_t 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 c56dcc1..c4b89f8 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -318,7 +318,7 @@
audio_session_t triggerSession,
audio_session_t listenerSession,
sync_event_callback_t callBack,
- wp<RefBase> cookie);
+ const wp<RefBase>& cookie);
private:
@@ -485,7 +485,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();
@@ -507,7 +507,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,
audio_session_t triggerSession);
@@ -540,8 +540,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
@@ -712,9 +712,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 e3e518c..ae9accf 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -1433,7 +1433,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 322c06a..626fcc1 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -358,7 +358,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 16ec278..d37c0d3 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 c7aa26b..1907e12 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1153,7 +1153,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);
@@ -2929,14 +2929,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 1d5d3c8..bcc0a2e 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
@@ -616,9 +616,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);
@@ -1036,7 +1036,7 @@
class AsyncCallbackThread : public Thread {
public:
- AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
+ explicit AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
virtual ~AsyncCallbackThread();
@@ -1121,7 +1121,7 @@
class ResamplerBufferProvider : public AudioBufferProvider
{
public:
- ResamplerBufferProvider(RecordTrack* recordTrack) :
+ explicit ResamplerBufferProvider(RecordTrack* recordTrack) :
mRecordTrack(recordTrack),
mRsmpInUnrel(0), mRsmpInFront(0) { }
virtual ~ResamplerBufferProvider() { }