summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-01-05 07:38:29 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-05 07:38:29 -0800
commita8719ad9d53d3fe51e8031b2471e9558b8ef727f (patch)
treeb64e560b500236cbe7f9f31b26a5c5f2032373e7
parent9a03482c66b2f5c30c7fde38216239a1f233df02 (diff)
parente80a4ccd2bac7bf121441e257044f5813e85180f (diff)
downloadframeworks_base-a8719ad9d53d3fe51e8031b2471e9558b8ef727f.zip
frameworks_base-a8719ad9d53d3fe51e8031b2471e9558b8ef727f.tar.gz
frameworks_base-a8719ad9d53d3fe51e8031b2471e9558b8ef727f.tar.bz2
Merge "Use the standard CC_LIKELY and CC_UNLIKELY macros"
-rw-r--r--libs/gui/ISurfaceComposer.cpp5
-rw-r--r--libs/gui/ISurfaceComposerClient.cpp3
-rw-r--r--libs/rs/driver/rsdRuntimeMath.cpp10
-rw-r--r--media/libeffects/testlibs/AudioBiquadFilter.cpp12
-rw-r--r--media/libeffects/testlibs/AudioCoefInterpolator.cpp12
-rw-r--r--media/libeffects/testlibs/AudioCommon.h5
-rw-r--r--media/libeffects/testlibs/AudioPeakingFilter.cpp12
-rw-r--r--media/libeffects/testlibs/AudioShelvingFilter.cpp8
-rw-r--r--media/libmedia/AudioRecord.cpp10
-rw-r--r--media/libmedia/AudioTrack.cpp10
-rw-r--r--services/audioflinger/AudioFlinger.cpp33
-rw-r--r--services/audioflinger/AudioFlinger.h6
-rw-r--r--services/audioflinger/AudioMixer.cpp37
-rw-r--r--services/audioflinger/AudioMixer.h5
-rw-r--r--services/surfaceflinger/LayerBase.cpp4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp28
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h5
17 files changed, 90 insertions, 115 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index db32827..ca7c8f8 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -40,11 +40,6 @@
// ---------------------------------------------------------------------------
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
-// ---------------------------------------------------------------------------
-
namespace android {
class IDisplayEventConnection;
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index ace16aa..5ebdbd9 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -42,9 +42,6 @@
#define AID_GRAPHICS 1003
#endif
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
// ---------------------------------------------------------------------------
namespace android {
diff --git a/libs/rs/driver/rsdRuntimeMath.cpp b/libs/rs/driver/rsdRuntimeMath.cpp
index d29da7e..b927ed2 100644
--- a/libs/rs/driver/rsdRuntimeMath.cpp
+++ b/libs/rs/driver/rsdRuntimeMath.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <cutils/compiler.h>
+
#include "rsContext.h"
#include "rsScriptC.h"
#include "rsMatrix4x4.h"
@@ -306,7 +308,7 @@ static int32_t SC_AtomicSub(volatile int32_t *ptr, int32_t value) {
do {
prev = *ptr;
status = android_atomic_release_cas(prev, prev - value, ptr);
- } while (__builtin_expect(status != 0, 0));
+ } while (CC_UNLIKELY(status != 0));
return prev;
}
@@ -323,7 +325,7 @@ static int32_t SC_AtomicXor(volatile int32_t *ptr, int32_t value) {
do {
prev = *ptr;
status = android_atomic_release_cas(prev, prev ^ value, ptr);
- } while (__builtin_expect(status != 0, 0));
+ } while (CC_UNLIKELY(status != 0));
return prev;
}
@@ -333,7 +335,7 @@ static int32_t SC_AtomicMin(volatile int32_t *ptr, int32_t value) {
prev = *ptr;
int32_t n = rsMin(value, prev);
status = android_atomic_release_cas(prev, n, ptr);
- } while (__builtin_expect(status != 0, 0));
+ } while (CC_UNLIKELY(status != 0));
return prev;
}
@@ -343,7 +345,7 @@ static int32_t SC_AtomicMax(volatile int32_t *ptr, int32_t value) {
prev = *ptr;
int32_t n = rsMax(value, prev);
status = android_atomic_release_cas(prev, n, ptr);
- } while (__builtin_expect(status != 0, 0));
+ } while (CC_UNLIKELY(status != 0));
return prev;
}
diff --git a/media/libeffects/testlibs/AudioBiquadFilter.cpp b/media/libeffects/testlibs/AudioBiquadFilter.cpp
index 72917a3..16dd1c5 100644
--- a/media/libeffects/testlibs/AudioBiquadFilter.cpp
+++ b/media/libeffects/testlibs/AudioBiquadFilter.cpp
@@ -17,12 +17,10 @@
#include <string.h>
#include <assert.h>
+#include <cutils/compiler.h>
#include "AudioBiquadFilter.h"
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
namespace android {
const audio_coef_t AudioBiquadFilter::IDENTITY_COEFS[AudioBiquadFilter::NUM_COEFS] = { AUDIO_COEF_ONE, 0, 0, 0, 0 };
@@ -55,7 +53,7 @@ void AudioBiquadFilter::clear() {
void AudioBiquadFilter::setCoefs(const audio_coef_t coefs[NUM_COEFS], bool immediate) {
memcpy(mTargetCoefs, coefs, sizeof(mTargetCoefs));
if (mState & STATE_ENABLED_MASK) {
- if (UNLIKELY(immediate)) {
+ if (CC_UNLIKELY(immediate)) {
memcpy(mCoefs, coefs, sizeof(mCoefs));
setState(STATE_NORMAL);
} else {
@@ -70,7 +68,7 @@ void AudioBiquadFilter::process(const audio_sample_t in[], audio_sample_t out[],
}
void AudioBiquadFilter::enable(bool immediate) {
- if (UNLIKELY(immediate)) {
+ if (CC_UNLIKELY(immediate)) {
memcpy(mCoefs, mTargetCoefs, sizeof(mCoefs));
setState(STATE_NORMAL);
} else {
@@ -79,7 +77,7 @@ void AudioBiquadFilter::enable(bool immediate) {
}
void AudioBiquadFilter::disable(bool immediate) {
- if (UNLIKELY(immediate)) {
+ if (CC_UNLIKELY(immediate)) {
memcpy(mCoefs, IDENTITY_COEFS, sizeof(mCoefs));
setState(STATE_BYPASS);
} else {
@@ -142,7 +140,7 @@ void AudioBiquadFilter::process_bypass(const audio_sample_t * in,
audio_sample_t * out,
int frameCount) {
// The common case is in-place processing, because this is what the EQ does.
- if (UNLIKELY(in != out)) {
+ if (CC_UNLIKELY(in != out)) {
memcpy(out, in, frameCount * mNumChannels * sizeof(audio_sample_t));
}
}
diff --git a/media/libeffects/testlibs/AudioCoefInterpolator.cpp b/media/libeffects/testlibs/AudioCoefInterpolator.cpp
index 039ab9f..6b56922 100644
--- a/media/libeffects/testlibs/AudioCoefInterpolator.cpp
+++ b/media/libeffects/testlibs/AudioCoefInterpolator.cpp
@@ -16,10 +16,10 @@
*/
#include <string.h>
-#include "AudioCoefInterpolator.h"
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
+
+#include "AudioCoefInterpolator.h"
namespace android {
@@ -44,9 +44,9 @@ void AudioCoefInterpolator::getCoef(const int intCoord[], uint32_t fracCoord[],
size_t index = 0;
size_t dim = mNumInDims;
while (dim-- > 0) {
- if (UNLIKELY(intCoord[dim] < 0)) {
+ if (CC_UNLIKELY(intCoord[dim] < 0)) {
fracCoord[dim] = 0;
- } else if (UNLIKELY(intCoord[dim] >= (int)mInDims[dim] - 1)) {
+ } else if (CC_UNLIKELY(intCoord[dim] >= (int)mInDims[dim] - 1)) {
fracCoord[dim] = 0;
index += mInDimOffsets[dim] * (mInDims[dim] - 1);
} else {
@@ -63,7 +63,7 @@ void AudioCoefInterpolator::getCoefRecurse(size_t index,
memcpy(out, mTable + index, mNumOutDims * sizeof(audio_coef_t));
} else {
getCoefRecurse(index, fracCoord, out, dim + 1);
- if (LIKELY(fracCoord != 0)) {
+ if (CC_LIKELY(fracCoord != 0)) {
audio_coef_t tempCoef[MAX_OUT_DIMS];
getCoefRecurse(index + mInDimOffsets[dim], fracCoord, tempCoef,
dim + 1);
diff --git a/media/libeffects/testlibs/AudioCommon.h b/media/libeffects/testlibs/AudioCommon.h
index 444f93a..e8080dc 100644
--- a/media/libeffects/testlibs/AudioCommon.h
+++ b/media/libeffects/testlibs/AudioCommon.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <stddef.h>
+#include <cutils/compiler.h>
namespace android {
@@ -76,9 +77,9 @@ inline int16_t audio_sample_t_to_s15(audio_sample_t sample) {
// Convert a audio_sample_t sample to S15 (with clipping)
inline int16_t audio_sample_t_to_s15_clip(audio_sample_t sample) {
// TODO: optimize for targets supporting this as an atomic operation.
- if (__builtin_expect(sample >= (0x7FFF << 9), 0)) {
+ if (CC_UNLIKELY(sample >= (0x7FFF << 9))) {
return 0x7FFF;
- } else if (__builtin_expect(sample <= -(0x8000 << 9), 0)) {
+ } else if (CC_UNLIKELY(sample <= -(0x8000 << 9))) {
return 0x8000;
} else {
return audio_sample_t_to_s15(sample);
diff --git a/media/libeffects/testlibs/AudioPeakingFilter.cpp b/media/libeffects/testlibs/AudioPeakingFilter.cpp
index 60fefe6..99323ac 100644
--- a/media/libeffects/testlibs/AudioPeakingFilter.cpp
+++ b/media/libeffects/testlibs/AudioPeakingFilter.cpp
@@ -21,9 +21,7 @@
#include <new>
#include <assert.h>
-
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
namespace android {
// Format of the coefficient table:
@@ -66,12 +64,12 @@ void AudioPeakingFilter::reset() {
void AudioPeakingFilter::setFrequency(uint32_t millihertz) {
mNominalFrequency = millihertz;
- if (UNLIKELY(millihertz > mNiquistFreq / 2)) {
+ if (CC_UNLIKELY(millihertz > mNiquistFreq / 2)) {
millihertz = mNiquistFreq / 2;
}
uint32_t normFreq = static_cast<uint32_t>(
(static_cast<uint64_t>(millihertz) * mFrequencyFactor) >> 10);
- if (LIKELY(normFreq > (1 << 23))) {
+ if (CC_LIKELY(normFreq > (1 << 23))) {
mFrequency = (Effects_log2(normFreq) - ((32-9) << 15)) << (FREQ_PRECISION_BITS - 15);
} else {
mFrequency = 0;
@@ -107,11 +105,11 @@ void AudioPeakingFilter::getBandRange(uint32_t & low, uint32_t & high) const {
int32_t halfBW = (((mBandwidth + 1) / 2) << 15) / 1200;
low = static_cast<uint32_t>((static_cast<uint64_t>(mNominalFrequency) * Effects_exp2(-halfBW + (16 << 15))) >> 16);
- if (UNLIKELY(halfBW >= (16 << 15))) {
+ if (CC_UNLIKELY(halfBW >= (16 << 15))) {
high = mNiquistFreq;
} else {
high = static_cast<uint32_t>((static_cast<uint64_t>(mNominalFrequency) * Effects_exp2(halfBW + (16 << 15))) >> 16);
- if (UNLIKELY(high > mNiquistFreq)) {
+ if (CC_UNLIKELY(high > mNiquistFreq)) {
high = mNiquistFreq;
}
}
diff --git a/media/libeffects/testlibs/AudioShelvingFilter.cpp b/media/libeffects/testlibs/AudioShelvingFilter.cpp
index b8650ba..e031287 100644
--- a/media/libeffects/testlibs/AudioShelvingFilter.cpp
+++ b/media/libeffects/testlibs/AudioShelvingFilter.cpp
@@ -21,9 +21,7 @@
#include <new>
#include <assert.h>
-
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
namespace android {
// Format of the coefficient tables:
@@ -71,13 +69,13 @@ void AudioShelvingFilter::reset() {
void AudioShelvingFilter::setFrequency(uint32_t millihertz) {
mNominalFrequency = millihertz;
- if (UNLIKELY(millihertz > mNiquistFreq / 2)) {
+ if (CC_UNLIKELY(millihertz > mNiquistFreq / 2)) {
millihertz = mNiquistFreq / 2;
}
uint32_t normFreq = static_cast<uint32_t>(
(static_cast<uint64_t>(millihertz) * mFrequencyFactor) >> 10);
uint32_t log2minFreq = (mType == kLowShelf ? (32-10) : (32-2));
- if (LIKELY(normFreq > (1U << log2minFreq))) {
+ if (CC_LIKELY(normFreq > (1U << log2minFreq))) {
mFrequency = (Effects_log2(normFreq) - (log2minFreq << 15)) << (FREQ_PRECISION_BITS - 15);
} else {
mFrequency = 0;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 1d8e15b..dd1c6a5 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -39,9 +39,7 @@
#include <system/audio.h>
#include <cutils/bitops.h>
-
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
namespace android {
// ---------------------------------------------------------------------------
@@ -513,11 +511,11 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
goto start_loop_here;
while (framesReady == 0) {
active = mActive;
- if (UNLIKELY(!active)) {
+ if (CC_UNLIKELY(!active)) {
cblk->lock.unlock();
return NO_MORE_BUFFERS;
}
- if (UNLIKELY(!waitCount)) {
+ if (CC_UNLIKELY(!waitCount)) {
cblk->lock.unlock();
return WOULD_BLOCK;
}
@@ -534,7 +532,7 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
if (cblk->flags & CBLK_INVALID_MSK) {
goto create_new_record;
}
- if (__builtin_expect(result!=NO_ERROR, false)) {
+ if (CC_UNLIKELY(result != NO_ERROR)) {
cblk->waitTimeMs += waitTimeMs;
if (cblk->waitTimeMs >= cblk->bufferTimeoutMs) {
LOGW( "obtainBuffer timed out (is the CPU pegged?) "
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 6868d99..e0c6ca5 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -38,13 +38,11 @@
#include <utils/Atomic.h>
#include <cutils/bitops.h>
+#include <cutils/compiler.h>
#include <system/audio.h>
#include <system/audio_policy.h>
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
namespace android {
// ---------------------------------------------------------------------------
@@ -856,12 +854,12 @@ status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
goto start_loop_here;
while (framesAvail == 0) {
active = mActive;
- if (UNLIKELY(!active)) {
+ if (CC_UNLIKELY(!active)) {
ALOGV("Not active and NO_MORE_BUFFERS");
cblk->lock.unlock();
return NO_MORE_BUFFERS;
}
- if (UNLIKELY(!waitCount)) {
+ if (CC_UNLIKELY(!waitCount)) {
cblk->lock.unlock();
return WOULD_BLOCK;
}
@@ -879,7 +877,7 @@ status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
if (cblk->flags & CBLK_INVALID_MSK) {
goto create_new_track;
}
- if (__builtin_expect(result!=NO_ERROR, false)) {
+ if (CC_UNLIKELY(result != NO_ERROR)) {
cblk->waitTimeMs += waitTimeMs;
if (cblk->waitTimeMs >= cblk->bufferTimeoutMs) {
// timing out when a loop has been set and we have already written upto loop end
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index d055a8e..8255823 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -35,6 +35,7 @@
#include <cutils/bitops.h>
#include <cutils/properties.h>
+#include <cutils/compiler.h>
#include <media/AudioTrack.h>
#include <media/AudioRecord.h>
@@ -1930,8 +1931,8 @@ bool AudioFlinger::MixerThread::threadLoop()
const SortedVector< wp<Track> >& activeTracks = mActiveTracks;
// put audio hardware into standby after short delay
- if UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
- mSuspended) {
+ if (CC_UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
+ mSuspended)) {
if (!mStandby) {
ALOGV("Audio hardware entering standby, mixer %p, mSuspended %d\n", this, mSuspended);
mOutput->stream->common.standby(&mOutput->stream->common);
@@ -1976,7 +1977,7 @@ bool AudioFlinger::MixerThread::threadLoop()
lockEffectChains_l(effectChains);
}
- if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+ if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
// mix buffers...
mAudioMixer->process();
sleepTime = 0;
@@ -2264,7 +2265,7 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
// remove all the tracks that need to be...
count = tracksToRemove->size();
- if (UNLIKELY(count)) {
+ if (CC_UNLIKELY(count)) {
for (size_t i=0 ; i<count ; i++) {
const sp<Track>& track = tracksToRemove->itemAt(i);
mActiveTracks.remove(track);
@@ -2599,8 +2600,8 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
}
// put audio hardware into standby after short delay
- if UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
- mSuspended) {
+ if (CC_UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
+ mSuspended)) {
// wait until we have something to do...
if (!mStandby) {
ALOGV("Audio hardware entering standby, mixer %p\n", this);
@@ -2750,7 +2751,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
}
// remove all the tracks that need to be...
- if (UNLIKELY(trackToRemove != 0)) {
+ if (CC_UNLIKELY(trackToRemove != 0)) {
mActiveTracks.remove(trackToRemove);
if (!effectChains.isEmpty()) {
ALOGV("stopping track on chain %p for session Id: %d", effectChains[0].get(),
@@ -2765,7 +2766,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
lockEffectChains_l(effectChains);
}
- if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+ if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
AudioBufferProvider::Buffer buffer;
size_t frameCount = mFrameCount;
curBuf = (int8_t *)mMixBuffer;
@@ -2773,7 +2774,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
while (frameCount) {
buffer.frameCount = frameCount;
activeTrack->getNextBuffer(&buffer);
- if (UNLIKELY(buffer.raw == NULL)) {
+ if (CC_UNLIKELY(buffer.raw == NULL)) {
memset(curBuf, 0, frameCount * mFrameSize);
break;
}
@@ -2992,8 +2993,8 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
}
// put audio hardware into standby after short delay
- if UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
- mSuspended) {
+ if (CC_UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
+ mSuspended)) {
if (!mStandby) {
for (size_t i = 0; i < outputTracks.size(); i++) {
outputTracks[i]->stop();
@@ -3038,7 +3039,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
lockEffectChains_l(effectChains);
}
- if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+ if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
// mix buffers...
if (outputsReady(outputTracks)) {
mAudioMixer->process();
@@ -3451,7 +3452,7 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer(AudioBufferProvider:
framesReady = cblk->framesReady();
- if (LIKELY(framesReady)) {
+ if (CC_LIKELY(framesReady)) {
uint32_t s = cblk->server;
uint32_t bufferEnd = cblk->serverBase + cblk->frameCount;
@@ -3700,7 +3701,7 @@ status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvi
framesAvail = cblk->framesAvailable_l();
- if (LIKELY(framesAvail)) {
+ if (CC_LIKELY(framesAvail)) {
uint32_t s = cblk->server;
uint32_t bufferEnd = cblk->serverBase + cblk->frameCount;
@@ -3953,7 +3954,7 @@ status_t AudioFlinger::PlaybackThread::OutputTrack::obtainBuffer(AudioBufferProv
goto start_loop_here;
while (framesAvail == 0) {
active = mActive;
- if (UNLIKELY(!active)) {
+ if (CC_UNLIKELY(!active)) {
ALOGV("Not active and NO_MORE_BUFFERS");
return AudioTrack::NO_MORE_BUFFERS;
}
@@ -4331,7 +4332,7 @@ bool AudioFlinger::RecordThread::threadLoop()
}
buffer.frameCount = mFrameCount;
- if (LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) {
+ if (CC_LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) {
size_t framesOut = buffer.frameCount;
if (mResampler == NULL) {
// no resampling
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 9707cf4..7baa8fc 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -55,12 +55,6 @@ class AudioResampler;
// ----------------------------------------------------------------------------
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
-
-// ----------------------------------------------------------------------------
-
static const nsecs_t kStandbyTimeInNsecs = seconds(3);
class AudioFlinger :
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index d230d27..d994a87 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -28,6 +28,7 @@
#include <utils/Log.h>
#include <cutils/bitops.h>
+#include <cutils/compiler.h>
#include <system/audio.h>
@@ -506,13 +507,13 @@ void AudioMixer::track__genericResample(track_t* t, int32_t* out, size_t outFram
t->resampler->setVolume(UNITY_GAIN, UNITY_GAIN);
memset(temp, 0, outFrameCount * MAX_NUM_CHANNELS * sizeof(int32_t));
t->resampler->resample(temp, outFrameCount, t->bufferProvider);
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
volumeRampStereo(t, out, outFrameCount, temp, aux);
} else {
volumeStereo(t, out, outFrameCount, temp, aux);
}
} else {
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
t->resampler->setVolume(UNITY_GAIN, UNITY_GAIN);
memset(temp, 0, outFrameCount * MAX_NUM_CHANNELS * sizeof(int32_t));
t->resampler->resample(temp, outFrameCount, t->bufferProvider);
@@ -543,7 +544,7 @@ void AudioMixer::volumeRampStereo(track_t* t, int32_t* out, size_t frameCount, i
// (vl + vlInc*frameCount)/65536.0f, frameCount);
// ramp volume
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
int32_t va = t->prevAuxLevel;
const int32_t vaInc = t->auxInc;
int32_t l;
@@ -578,7 +579,7 @@ void AudioMixer::volumeStereo(track_t* t, int32_t* out, size_t frameCount, int32
const int16_t vl = t->volume[0];
const int16_t vr = t->volume[1];
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
const int16_t va = (int16_t)t->auxLevel;
do {
int16_t l = (int16_t)(*temp++ >> 12);
@@ -605,11 +606,11 @@ void AudioMixer::track__16BitsStereo(track_t* t, int32_t* out, size_t frameCount
{
int16_t const *in = static_cast<int16_t const *>(t->in);
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
int32_t l;
int32_t r;
// ramp gain
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
int32_t vl = t->prevVolume[0];
int32_t vr = t->prevVolume[1];
int32_t va = t->prevAuxLevel;
@@ -654,7 +655,7 @@ void AudioMixer::track__16BitsStereo(track_t* t, int32_t* out, size_t frameCount
}
} else {
// ramp gain
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
int32_t vl = t->prevVolume[0];
int32_t vr = t->prevVolume[1];
const int32_t vlInc = t->volumeInc[0];
@@ -695,9 +696,9 @@ void AudioMixer::track__16BitsMono(track_t* t, int32_t* out, size_t frameCount,
{
int16_t const *in = static_cast<int16_t const *>(t->in);
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
// ramp gain
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
int32_t vl = t->prevVolume[0];
int32_t vr = t->prevVolume[1];
int32_t va = t->prevAuxLevel;
@@ -740,7 +741,7 @@ void AudioMixer::track__16BitsMono(track_t* t, int32_t* out, size_t frameCount,
}
} else {
// ramp gain
- if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+ if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
int32_t vl = t->prevVolume[0];
int32_t vr = t->prevVolume[1];
const int32_t vlInc = t->volumeInc[0];
@@ -793,7 +794,7 @@ void AudioMixer::process__nop(state_t* state)
i = 31 - __builtin_clz(e2);
e2 &= ~(1<<i);
track_t& t2 = state->tracks[i];
- if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+ if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
e1 &= ~(1<<i);
}
}
@@ -851,7 +852,7 @@ void AudioMixer::process__genericNoResampling(state_t* state)
j = 31 - __builtin_clz(e2);
e2 &= ~(1<<j);
track_t& t2 = state->tracks[j];
- if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+ if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
e1 &= ~(1<<j);
}
}
@@ -868,7 +869,7 @@ void AudioMixer::process__genericNoResampling(state_t* state)
track_t& t = state->tracks[i];
size_t outFrames = BLOCKSIZE;
int32_t *aux = NULL;
- if UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED) {
+ if (CC_UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED)) {
aux = t.auxBuffer + numFrames;
}
while (outFrames) {
@@ -877,7 +878,7 @@ void AudioMixer::process__genericNoResampling(state_t* state)
(t.hook)(&t, outTemp + (BLOCKSIZE-outFrames)*MAX_NUM_CHANNELS, inFrames, state->resampleTemp, aux);
t.frameCount -= inFrames;
outFrames -= inFrames;
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
aux += inFrames;
}
}
@@ -932,7 +933,7 @@ void AudioMixer::process__genericResampling(state_t* state)
j = 31 - __builtin_clz(e2);
e2 &= ~(1<<j);
track_t& t2 = state->tracks[j];
- if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+ if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
e1 &= ~(1<<j);
}
}
@@ -944,7 +945,7 @@ void AudioMixer::process__genericResampling(state_t* state)
e1 &= ~(1<<i);
track_t& t = state->tracks[i];
int32_t *aux = NULL;
- if UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED) {
+ if (CC_UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED)) {
aux = t.auxBuffer;
}
@@ -965,7 +966,7 @@ void AudioMixer::process__genericResampling(state_t* state)
// been enabled for mixing.
if (t.in == NULL) break;
- if UNLIKELY(aux != NULL) {
+ if (CC_UNLIKELY(aux != NULL)) {
aux += outFrames;
}
(t.hook)(&t, outTemp + outFrames*MAX_NUM_CHANNELS, t.buffer.frameCount, state->resampleTemp, aux);
@@ -1007,7 +1008,7 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state)
}
size_t outFrames = b.frameCount;
- if (UNLIKELY(uint32_t(vl) > UNITY_GAIN || uint32_t(vr) > UNITY_GAIN)) {
+ if (CC_UNLIKELY(uint32_t(vl) > UNITY_GAIN || uint32_t(vr) > UNITY_GAIN)) {
// volume is boosted, so we might need to clamp even though
// we process only one track.
do {
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 8ba5073..9c129b8 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -28,11 +28,6 @@ namespace android {
// ----------------------------------------------------------------------------
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
-// ----------------------------------------------------------------------------
-
class AudioMixer
{
public:
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index f04add1..37879f1 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -240,7 +240,7 @@ void LayerBase::validateVisibility(const Transform& planeTransform)
for (size_t i=0 ; i<4 ; i++)
mVertices[i][1] = hw_h - mVertices[i][1];
- if (UNLIKELY(transformed)) {
+ if (CC_UNLIKELY(transformed)) {
// NOTE: here we could also punt if we have too many rectangles
// in the transparent region
if (tr.preserveRects()) {
@@ -416,7 +416,7 @@ void LayerBase::drawWithOpenGL(const Region& clip) const
const State& s(drawingState());
GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
- if (UNLIKELY(s.alpha < 0xFF)) {
+ if (CC_UNLIKELY(s.alpha < 0xFF)) {
const GLfloat alpha = s.alpha * (1.0f/255.0f);
if (mPremultipliedAlpha) {
glColor4f(alpha, alpha, alpha, alpha);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 96a0fd66..789e03c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -404,14 +404,14 @@ bool SurfaceFlinger::threadLoop()
waitForEvent();
// check for transactions
- if (UNLIKELY(mConsoleSignals)) {
+ if (CC_UNLIKELY(mConsoleSignals)) {
handleConsoleEvents();
}
// if we're in a global transaction, don't do anything.
const uint32_t mask = eTransactionNeeded | eTraversalNeeded;
uint32_t transactionFlags = peekTransactionFlags(mask);
- if (UNLIKELY(transactionFlags)) {
+ if (CC_UNLIKELY(transactionFlags)) {
handleTransaction(transactionFlags);
}
@@ -423,13 +423,13 @@ bool SurfaceFlinger::threadLoop()
return true;
}
- if (UNLIKELY(mHwWorkListDirty)) {
+ if (CC_UNLIKELY(mHwWorkListDirty)) {
// build the h/w work list
handleWorkList();
}
const DisplayHardware& hw(graphicPlane(0).displayHardware());
- if (LIKELY(hw.canDraw())) {
+ if (CC_LIKELY(hw.canDraw())) {
// repaint the framebuffer (if needed)
const int index = hw.getCurrentBufferIndex();
@@ -629,7 +629,7 @@ void SurfaceFlinger::computeVisibleRegions(
// handle hidden surfaces by setting the visible region to empty
- if (LIKELY(!(s.flags & ISurfaceComposer::eLayerHidden) && s.alpha)) {
+ if (CC_LIKELY(!(s.flags & ISurfaceComposer::eLayerHidden) && s.alpha)) {
const bool translucent = !layer->isOpaque();
const Rect bounds(layer->visibleBounds());
visibleRegion.set(bounds);
@@ -814,7 +814,7 @@ void SurfaceFlinger::handleRepaint()
// compute the invalid region
mSwapRegion.orSelf(mDirtyRegion);
- if (UNLIKELY(mDebugRegion)) {
+ if (CC_UNLIKELY(mDebugRegion)) {
debugFlashRegions();
}
@@ -968,7 +968,7 @@ void SurfaceFlinger::composeSurfaces(const Region& dirty)
HWComposer& hwc(hw.getHwComposer());
const size_t fbLayerCount = hwc.getLayerCount(HWC_FRAMEBUFFER);
- if (UNLIKELY(fbLayerCount && !mWormholeRegion.isEmpty())) {
+ if (CC_UNLIKELY(fbLayerCount && !mWormholeRegion.isEmpty())) {
// should never happen unless the window manager has a bug
// draw something...
drawWormhole();
@@ -1053,7 +1053,7 @@ void SurfaceFlinger::drawWormhole() const
const int32_t width = hw.getWidth();
const int32_t height = hw.getHeight();
- if (LIKELY(!mDebugBackground)) {
+ if (CC_LIKELY(!mDebugBackground)) {
glClearColor(0,0,0,0);
Region::const_iterator it = region.begin();
Region::const_iterator const end = region.end();
@@ -1257,7 +1257,7 @@ void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state,
int SurfaceFlinger::setOrientation(DisplayID dpy,
int orientation, uint32_t flags)
{
- if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
+ if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
return BAD_VALUE;
Mutex::Autolock _l(mStateLock);
@@ -1356,7 +1356,7 @@ sp<Layer> SurfaceFlinger::createNormalSurface(
sp<Layer> layer = new Layer(this, display, client);
status_t err = layer->setBuffers(w, h, format, flags);
- if (LIKELY(err != NO_ERROR)) {
+ if (CC_LIKELY(err != NO_ERROR)) {
LOGE("createNormalSurfaceLocked() failed (%s)", strerror(-err));
layer.clear();
}
@@ -1676,7 +1676,7 @@ status_t SurfaceFlinger::onTransact(
status_t err = BnSurfaceComposer::onTransact(code, data, reply, flags);
if (err == UNKNOWN_TRANSACTION || err == PERMISSION_DENIED) {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
- if (UNLIKELY(!PermissionCache::checkCallingPermission(sHardwareTest))) {
+ if (CC_UNLIKELY(!PermissionCache::checkCallingPermission(sHardwareTest))) {
IPCThreadState* ipc = IPCThreadState::self();
const int pid = ipc->getCallingPid();
const int uid = ipc->getCallingUid();
@@ -2261,7 +2261,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
status_t result = PERMISSION_DENIED;
// only one display supported for now
- if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
+ if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
return BAD_VALUE;
if (!GLExtensions::getInstance().haveFramebufferObject())
@@ -2383,7 +2383,7 @@ status_t SurfaceFlinger::captureScreen(DisplayID dpy,
uint32_t minLayerZ, uint32_t maxLayerZ)
{
// only one display supported for now
- if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
+ if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
return BAD_VALUE;
if (!GLExtensions::getInstance().haveFramebufferObject())
@@ -2511,7 +2511,7 @@ status_t Client::onTransact(
const int pid = ipc->getCallingPid();
const int uid = ipc->getCallingUid();
const int self_pid = getpid();
- if (UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != 0)) {
+ if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != 0)) {
// we're called from a different process, do the real check
if (!PermissionCache::checkCallingPermission(sAccessSurfaceFlinger))
{
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 41caee3..ffd3ac9 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <sys/types.h>
+#include <cutils/compiler.h>
+
#include <utils/Atomic.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
@@ -53,9 +55,6 @@ class LayerDim;
class LayerScreenshot;
struct surface_flinger_cblk_t;
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
// ---------------------------------------------------------------------------
class Client : public BnSurfaceComposerClient