"if" statements use curly braces per media style
Change-Id: I130e7849fd1da7a0b7fe56c3c53919d26e3843b8
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 0587651..dd0a145 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -643,10 +643,12 @@
status_t err = obtainBuffer(&audioBuffer, ((2 * MAX_RUN_TIMEOUT_MS) / WAIT_PERIOD_MS));
if (err < 0) {
// out of buffers, return #bytes written
- if (err == status_t(NO_MORE_BUFFERS))
+ if (err == status_t(NO_MORE_BUFFERS)) {
break;
- if (err == status_t(TIMED_OUT))
+ }
+ if (err == status_t(TIMED_OUT)) {
err = 0;
+ }
return ssize_t(err);
}
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 979ee37..3056b4c 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -54,7 +54,9 @@
audio_stream_type_t streamType,
uint32_t sampleRate)
{
- if (frameCount == NULL) return BAD_VALUE;
+ if (frameCount == NULL) {
+ return BAD_VALUE;
+ }
// default to 0 in case of error
*frameCount = 0;
@@ -553,7 +555,9 @@
return NO_INIT;
}
// Resampler implementation limits input sampling rate to 2 x output sampling rate.
- if (rate == 0 || rate > afSamplingRate*2 ) return BAD_VALUE;
+ if (rate == 0 || rate > afSamplingRate*2 ) {
+ return BAD_VALUE;
+ }
AutoMutex lock(mLock);
mCblk->sampleRate = rate;
@@ -620,7 +624,9 @@
status_t AudioTrack::setMarkerPosition(uint32_t marker)
{
- if (mCbf == NULL) return INVALID_OPERATION;
+ if (mCbf == NULL) {
+ return INVALID_OPERATION;
+ }
mMarkerPosition = marker;
mMarkerReached = false;
@@ -630,7 +636,9 @@
status_t AudioTrack::getMarkerPosition(uint32_t *marker) const
{
- if (marker == NULL) return BAD_VALUE;
+ if (marker == NULL) {
+ return BAD_VALUE;
+ }
*marker = mMarkerPosition;
@@ -639,7 +647,9 @@
status_t AudioTrack::setPositionUpdatePeriod(uint32_t updatePeriod)
{
- if (mCbf == NULL) return INVALID_OPERATION;
+ if (mCbf == NULL) {
+ return INVALID_OPERATION;
+ }
uint32_t curPosition;
getPosition(&curPosition);
@@ -651,7 +661,9 @@
status_t AudioTrack::getPositionUpdatePeriod(uint32_t *updatePeriod) const
{
- if (updatePeriod == NULL) return BAD_VALUE;
+ if (updatePeriod == NULL) {
+ return BAD_VALUE;
+ }
*updatePeriod = mUpdatePeriod;
@@ -660,16 +672,22 @@
status_t AudioTrack::setPosition(uint32_t position)
{
- if (mIsTimed) return INVALID_OPERATION;
+ if (mIsTimed) {
+ return INVALID_OPERATION;
+ }
AutoMutex lock(mLock);
- if (!stopped_l()) return INVALID_OPERATION;
+ if (!stopped_l()) {
+ return INVALID_OPERATION;
+ }
audio_track_cblk_t* cblk = mCblk;
Mutex::Autolock _l(cblk->lock);
- if (position > cblk->user) return BAD_VALUE;
+ if (position > cblk->user) {
+ return BAD_VALUE;
+ }
cblk->server = position;
android_atomic_or(CBLK_FORCEREADY, &cblk->flags);
@@ -679,7 +697,9 @@
status_t AudioTrack::getPosition(uint32_t *position)
{
- if (position == NULL) return BAD_VALUE;
+ if (position == NULL) {
+ return BAD_VALUE;
+ }
AutoMutex lock(mLock);
*position = mFlushed ? 0 : mCblk->server;
@@ -690,7 +710,9 @@
{
AutoMutex lock(mLock);
- if (!stopped_l()) return INVALID_OPERATION;
+ if (!stopped_l()) {
+ return INVALID_OPERATION;
+ }
flush_l();
@@ -1060,8 +1082,12 @@
ssize_t AudioTrack::write(const void* buffer, size_t userSize)
{
- if (mSharedBuffer != 0) return INVALID_OPERATION;
- if (mIsTimed) return INVALID_OPERATION;
+ if (mSharedBuffer != 0) {
+ return INVALID_OPERATION;
+ }
+ if (mIsTimed) {
+ return INVALID_OPERATION;
+ }
if (ssize_t(userSize) < 0) {
// Sanity-check: user is most-likely passing an error code, and it would
@@ -1098,8 +1124,9 @@
status_t err = obtainBuffer(&audioBuffer, -1);
if (err < 0) {
// out of buffers, return #bytes written
- if (err == status_t(NO_MORE_BUFFERS))
+ if (err == status_t(NO_MORE_BUFFERS)) {
break;
+ }
return ssize_t(err);
}
@@ -1159,8 +1186,9 @@
cblk = temp;
cblk->lock.unlock();
- if (result == OK)
+ if (result == OK) {
result = mAudioTrack->allocateTimedBuffer(size, buffer);
+ }
}
return result;
@@ -1218,7 +1246,9 @@
if (cblk->server == cblk->frameCount) {
mCbf(EVENT_BUFFER_END, mUserData, 0);
}
- if (mSharedBuffer != 0) return false;
+ if (mSharedBuffer != 0) {
+ return false;
+ }
}
}
@@ -1275,7 +1305,9 @@
}
break;
}
- if (err == status_t(STOPPED)) return false;
+ if (err == status_t(STOPPED)) {
+ return false;
+ }
// Divide buffer size by 2 to take into account the expansion
// due to 8 to 16 bit conversion: the callback must fill only half
@@ -1298,7 +1330,9 @@
break;
}
- if (writtenSize > reqSize) writtenSize = reqSize;
+ if (writtenSize > reqSize) {
+ writtenSize = reqSize;
+ }
if (mFormat == AUDIO_FORMAT_PCM_8_BIT && !(mFlags & AUDIO_OUTPUT_FLAG_DIRECT)) {
// 8 to 16 bit conversion, note that source and destination are the same address
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 384f268..9baa830 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -423,7 +423,9 @@
dumpTee(fd, mRecordTeeSource);
}
- if (locked) mLock.unlock();
+ if (locked) {
+ mLock.unlock();
+ }
}
return NO_ERROR;
}
@@ -2629,7 +2631,9 @@
clearOutputTracks();
- if (exitPending()) break;
+ if (exitPending()) {
+ break;
+ }
releaseWakeLock_l();
// wait until we have something to do...
@@ -2822,7 +2826,9 @@
bytesWritten = (int)mOutput->stream->write(mOutput->stream, mMixBuffer, mixBufferSize);
}
- if (bytesWritten > 0) mBytesWritten += mixBufferSize;
+ if (bytesWritten > 0) {
+ mBytesWritten += mixBufferSize;
+ }
mNumWrites++;
mInWrite = false;
}
@@ -2963,7 +2969,9 @@
for (size_t i=0 ; i<count ; i++) {
sp<Track> t = mActiveTracks[i].promote();
- if (t == 0) continue;
+ if (t == 0) {
+ continue;
+ }
// this const just means the local variable doesn't change
Track* const track = t.get();
@@ -3243,11 +3251,17 @@
// Convert volumes from 8.24 to 4.12 format
// This additional clamping is needed in case chain->setVolume_l() overshot
vl = (vl + (1 << 11)) >> 12;
- if (vl > MAX_GAIN_INT) vl = MAX_GAIN_INT;
+ if (vl > MAX_GAIN_INT) {
+ vl = MAX_GAIN_INT;
+ }
vr = (vr + (1 << 11)) >> 12;
- if (vr > MAX_GAIN_INT) vr = MAX_GAIN_INT;
+ if (vr > MAX_GAIN_INT) {
+ vr = MAX_GAIN_INT;
+ }
- if (va > MAX_GAIN_INT) va = MAX_GAIN_INT; // va is uint32_t, so no need to check for -
+ if (va > MAX_GAIN_INT) {
+ va = MAX_GAIN_INT; // va is uint32_t, so no need to check for -
+ }
// XXX: these things DON'T need to be done each time
mAudioMixer->setBufferProvider(name, track);
@@ -3376,7 +3390,9 @@
ALOG_ASSERT(i < count);
resetMask &= ~(1 << i);
sp<Track> t = mActiveTracks[i].promote();
- if (t == 0) continue;
+ if (t == 0) {
+ continue;
+ }
Track* track = t.get();
ALOG_ASSERT(track->isFastTrack() && track->isStopped());
track->reset();
@@ -3578,7 +3594,9 @@
mAudioMixer = new AudioMixer(mNormalFrameCount, mSampleRate);
for (size_t i = 0; i < mTracks.size() ; i++) {
int name = getTrackName_l(mTracks[i]->mChannelMask, mTracks[i]->mSessionId);
- if (name < 0) break;
+ if (name < 0) {
+ break;
+ }
mTracks[i]->mName = name;
// limit track sample rate to 2 x new output sample rate
if (mTracks[i]->mCblk->sampleRate > 2 * sampleRate()) {
@@ -3753,7 +3771,9 @@
if (mActiveTracks.size() != 0) {
sp<Track> t = mActiveTracks[0].promote();
// The track died recently
- if (t == 0) return MIXER_IDLE;
+ if (t == 0) {
+ return MIXER_IDLE;
+ }
Track* const track = t.get();
audio_track_cblk_t* cblk = track->cblk();
@@ -3792,10 +3812,14 @@
float v = mMasterVolume * typeVolume;
uint32_t vlr = cblk->getVolumeLR();
float v_clamped = v * (vlr & 0xFFFF);
- if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN;
+ if (v_clamped > MAX_GAIN) {
+ v_clamped = MAX_GAIN;
+ }
left = v_clamped/MAX_GAIN;
v_clamped = v * (vlr >> 16);
- if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN;
+ if (v_clamped > MAX_GAIN) {
+ v_clamped = MAX_GAIN;
+ }
right = v_clamped/MAX_GAIN;
}
@@ -4587,7 +4611,9 @@
// Don't call for fast tracks; the framesReady() could result in priority inversion
bool AudioFlinger::PlaybackThread::Track::isReady() const {
- if (mFillingUpStatus != FS_FILLING || isStopped() || isPausing()) return true;
+ if (mFillingUpStatus != FS_FILLING || isStopped() || isPausing()) {
+ return true;
+ }
if (framesReady() >= mCblk->frameCount ||
(mCblk->flags & CBLK_FORCEREADY)) {
@@ -5429,7 +5455,9 @@
// Check if last stepServer failed, try to step now
if (mStepServerFailed) {
- if (!step()) goto getNextBuffer_exit;
+ if (!step()) {
+ goto getNextBuffer_exit;
+ }
ALOGV("stepServer recovered");
mStepServerFailed = false;
}
@@ -6090,7 +6118,9 @@
if (mActiveTrack == 0 && mConfigEvents.isEmpty()) {
standby();
- if (exitPending()) break;
+ if (exitPending()) {
+ break;
+ }
releaseWakeLock_l();
ALOGV("RecordThread: loop stopping");
@@ -8122,7 +8152,9 @@
// indicate all active tracks in the chain
for (size_t i = 0 ; i < mActiveTracks.size() ; ++i) {
sp<Track> track = mActiveTracks[i].promote();
- if (track == 0) continue;
+ if (track == 0) {
+ continue;
+ }
if (session == track->sessionId()) {
ALOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
chain->incActiveTrackCnt();
@@ -8145,7 +8177,9 @@
size_t size = mEffectChains.size();
size_t i = 0;
for (i = 0; i < size; i++) {
- if (mEffectChains[i]->sessionId() < session) break;
+ if (mEffectChains[i]->sessionId() < session) {
+ break;
+ }
}
mEffectChains.insertAt(chain, i);
checkSuspendOnAddEffectChain_l(chain);
@@ -8165,7 +8199,9 @@
// detach all active tracks from the chain
for (size_t i = 0 ; i < mActiveTracks.size() ; ++i) {
sp<Track> track = mActiveTracks[i].promote();
- if (track == 0) continue;
+ if (track == 0) {
+ continue;
+ }
if (session == track->sessionId()) {
ALOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
chain.get(), session);
@@ -8332,11 +8368,15 @@
size_t i;
for (i = 0; i < size; i++) {
EffectHandle *h = mHandles[i];
- if (h == NULL || h->destroyed_l()) continue;
+ if (h == NULL || h->destroyed_l()) {
+ continue;
+ }
// first non destroyed handle is considered in control
if (controlHandle == NULL)
controlHandle = h;
- if (h->priority() <= priority) break;
+ if (h->priority() <= priority) {
+ break;
+ }
}
// if inserted in first place, move effect control from previous owner to this handle
if (i == 0) {
@@ -8361,7 +8401,9 @@
size_t size = mHandles.size();
size_t i;
for (i = 0; i < size; i++) {
- if (mHandles[i] == handle) break;
+ if (mHandles[i] == handle) {
+ break;
+ }
}
if (i == size) {
return size;
@@ -9070,8 +9112,12 @@
status_t AudioFlinger::EffectHandle::enable()
{
ALOGV("enable %p", this);
- if (!mHasControl) return INVALID_OPERATION;
- if (mEffect == 0) return DEAD_OBJECT;
+ if (!mHasControl) {
+ return INVALID_OPERATION;
+ }
+ if (mEffect == 0) {
+ return DEAD_OBJECT;
+ }
if (mEnabled) {
return NO_ERROR;
@@ -9102,8 +9148,12 @@
status_t AudioFlinger::EffectHandle::disable()
{
ALOGV("disable %p", this);
- if (!mHasControl) return INVALID_OPERATION;
- if (mEffect == 0) return DEAD_OBJECT;
+ if (!mHasControl) {
+ return INVALID_OPERATION;
+ }
+ if (mEffect == 0) {
+ return DEAD_OBJECT;
+ }
if (!mEnabled) {
return NO_ERROR;
@@ -9170,8 +9220,12 @@
if (!mHasControl && cmdCode != EFFECT_CMD_GET_PARAM) {
return INVALID_OPERATION;
}
- if (mEffect == 0) return DEAD_OBJECT;
- if (mClient == 0) return INVALID_OPERATION;
+ if (mEffect == 0) {
+ return DEAD_OBJECT;
+ }
+ if (mClient == 0) {
+ return INVALID_OPERATION;
+ }
// handle commands that are not forwarded transparently to effect engine
if (cmdCode == EFFECT_CMD_SET_PARAM_COMMIT) {
@@ -9641,7 +9695,9 @@
uint32_t rVol = newRight;
for (size_t i = 0; i < size; i++) {
- if ((int)i == ctrlIdx) continue;
+ if ((int)i == ctrlIdx) {
+ continue;
+ }
// this also works for ctrlIdx == -1 when there is no volume controller
if ((int)i > ctrlIdx) {
lVol = *left;