audioflinger: Make use of android-base/macros.h
Replace local definitions of "array size" macro, and
declarations of non-copyable objects with corresponding
constructs from android-base/macros.h.
Also change "protected:" to "private:" for classes
not designed to be inherited.
Change-Id: I2d1e6d153511ed84d52fe6377879f83258890653
Test: make
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index d546ae3..e56a0f4 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -340,7 +340,6 @@
AUDIO_HARDWARE_MODULE_ID_A2DP,
AUDIO_HARDWARE_MODULE_ID_USB,
};
-#define ARRAY_SIZE(x) (sizeof((x))/sizeof(((x)[0])))
AudioHwDevice* AudioFlinger::findSuitableHwDev_l(
audio_module_handle_t module,
@@ -350,7 +349,7 @@
// well known modules
if (module == 0) {
ALOGW("findSuitableHwDev_l() loading well know audio hw modules");
- for (size_t i = 0; i < ARRAY_SIZE(audio_interfaces); i++) {
+ for (size_t i = 0; i < arraysize(audio_interfaces); i++) {
loadHwModule_l(audio_interfaces[i]);
}
// then try to find a module supporting the requested device.
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 5570d86..2e0bc66 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -25,6 +25,8 @@
#include <sys/types.h>
#include <limits.h>
+#include <android-base/macros.h>
+
#include <cutils/compiler.h>
#include <cutils/properties.h>
@@ -445,8 +447,8 @@
sp<AudioFlinger> audioFlinger() const { return mAudioFlinger; }
private:
- Client(const Client&);
- Client& operator = (const Client&);
+ DISALLOW_COPY_AND_ASSIGN(Client);
+
const sp<AudioFlinger> mAudioFlinger;
sp<MemoryDealer> mMemoryDealer;
const pid_t mPid;
@@ -466,8 +468,7 @@
virtual void binderDied(const wp<IBinder>& who);
private:
- NotificationClient(const NotificationClient&);
- NotificationClient& operator = (const NotificationClient&);
+ DISALLOW_COPY_AND_ASSIGN(NotificationClient);
const sp<AudioFlinger> mAudioFlinger;
const pid_t mPid;
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 0755c52..e37529e 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -135,15 +135,14 @@
void dump(int fd, const Vector<String16>& args);
-protected:
+private:
friend class AudioFlinger; // for mHandles
bool mPinned;
// Maximum time allocated to effect engines to complete the turn off sequence
static const uint32_t MAX_DISABLE_TIME_MS = 10000;
- EffectModule(const EffectModule&);
- EffectModule& operator = (const EffectModule&);
+ DISALLOW_COPY_AND_ASSIGN(EffectModule);
status_t start_l();
status_t stop_l();
@@ -232,10 +231,9 @@
void dumpToBuffer(char* buffer, size_t size);
-protected:
+private:
friend class AudioFlinger; // for mEffect, mHasControl, mEnabled
- EffectHandle(const EffectHandle&);
- EffectHandle& operator =(const EffectHandle&);
+ DISALLOW_COPY_AND_ASSIGN(EffectHandle);
Mutex mLock; // protects IEffect method calls
wp<EffectModule> mEffect; // pointer to controlled EffectModule
@@ -366,10 +364,9 @@
void dump(int fd, const Vector<String16>& args);
-protected:
+private:
friend class AudioFlinger; // for mThread, mEffects
- EffectChain(const EffectChain&);
- EffectChain& operator =(const EffectChain&);
+ DISALLOW_COPY_AND_ASSIGN(EffectChain);
class SuspendedEffectDesc : public RefBase {
public:
diff --git a/services/audioflinger/MmapTracks.h b/services/audioflinger/MmapTracks.h
index e4fe8ac..2a27dfd 100644
--- a/services/audioflinger/MmapTracks.h
+++ b/services/audioflinger/MmapTracks.h
@@ -41,11 +41,10 @@
static void appendDumpHeader(String8& result);
void dump(char* buffer, size_t size);
-protected:
+private:
friend class MmapThread;
- MmapTrack(const MmapTrack&);
- MmapTrack& operator = (const MmapTrack&);
+ DISALLOW_COPY_AND_ASSIGN(MmapTrack);
// AudioBufferProvider interface
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index f84ba08..3f1a0c0 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -94,8 +94,7 @@
friend class DirectOutputThread;
friend class OffloadThread;
- Track(const Track&);
- Track& operator = (const Track&);
+ DISALLOW_COPY_AND_ASSIGN(Track);
// AudioBufferProvider interface
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index 72ebc93..3f83ca8 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -65,8 +65,7 @@
private:
friend class AudioFlinger; // for mState
- RecordTrack(const RecordTrack&);
- RecordTrack& operator = (const RecordTrack&);
+ DISALLOW_COPY_AND_ASSIGN(RecordTrack);
// AudioBufferProvider interface
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 5cdabbc..9fa0d65 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -100,10 +100,6 @@
return a < b ? a : b;
}
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-#endif
-
namespace android {
// retry counts for buffer fill timeout
@@ -2182,7 +2178,7 @@
}
char buffer[256];
- track->dump(buffer, ARRAY_SIZE(buffer), false /* active */);
+ track->dump(buffer, arraysize(buffer), false /* active */);
mLocalLog.log("addTrack_l (%p) %s", track.get(), buffer + 4); // log for analysis
status = NO_ERROR;
@@ -2212,7 +2208,7 @@
track->triggerEvents(AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE);
char buffer[256];
- track->dump(buffer, ARRAY_SIZE(buffer), false /* active */);
+ track->dump(buffer, arraysize(buffer), false /* active */);
mLocalLog.log("removeTrack_l (%p) %s", track.get(), buffer + 4); // log for analysis
mTracks.remove(track);
@@ -3388,7 +3384,7 @@
removeTrack_l(track);
} else { // inactive but not terminated
char buffer[256];
- track->dump(buffer, ARRAY_SIZE(buffer), false /* active */);
+ track->dump(buffer, arraysize(buffer), false /* active */);
mLocalLog.log("removeTracks_l(%p) %s", track.get(), buffer + 4);
}
}
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index b950dc8..b352bd3 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -229,8 +229,7 @@
virtual void binderDied(const wp<IBinder>& who);
private:
- PMDeathRecipient(const PMDeathRecipient&);
- PMDeathRecipient& operator = (const PMDeathRecipient&);
+ DISALLOW_COPY_AND_ASSIGN(PMDeathRecipient);
wp<ThreadBase> mThread;
};
@@ -895,7 +894,7 @@
friend class AudioFlinger; // for numerous
- PlaybackThread& operator = (const PlaybackThread&);
+ DISALLOW_COPY_AND_ASSIGN(PlaybackThread);
status_t addTrack_l(const sp<Track>& track);
bool destroyTrack_l(const sp<Track>& track);
diff --git a/services/audioflinger/TrackBase.h b/services/audioflinger/TrackBase.h
index e0c09f7..cb540ca 100644
--- a/services/audioflinger/TrackBase.h
+++ b/services/audioflinger/TrackBase.h
@@ -92,8 +92,7 @@
protected:
- TrackBase(const TrackBase&);
- TrackBase& operator = (const TrackBase&);
+ DISALLOW_COPY_AND_ASSIGN(TrackBase);
// AudioBufferProvider interface
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer) = 0;