summaryrefslogtreecommitdiffstats
path: root/services
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
commita2a0a5d7d56baa831870f4bf2a0d942a477d92ef (patch)
tree1979692770dd902d0aa7e8c0760e496e13539e5c /services
parent7ab41c9f773ba599646f1b0d00955c1be80f92fd (diff)
parentf6b1678f8f508b447155a81b44e214475ab634a8 (diff)
downloadframeworks_av-a2a0a5d7d56baa831870f4bf2a0d942a477d92ef.zip
frameworks_av-a2a0a5d7d56baa831870f4bf2a0d942a477d92ef.tar.gz
frameworks_av-a2a0a5d7d56baa831870f4bf2a0d942a477d92ef.tar.bz2
Merge "Use the standard CC_LIKELY and CC_UNLIKELY macros"
Diffstat (limited to 'services')
-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
4 files changed, 36 insertions, 45 deletions
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: