Skip to content

Commit b8f9676

Browse files
committed
Cleanup DirectOutputThread::mActiveTrack
Rename activeTrack to mActiveTrack. Release the reference earlier, at the end of threadLoop_mix(). This allows the field to be made private and to move the declaration from PlaybackThread to DirectOutputThread. Change-Id: I02be7a254638f7d85e92aaf0002d20ca0092a5c3
1 parent 7ef9743 commit b8f9676

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,10 +2043,6 @@ if (mType == MIXER) {
20432043

20442044
processConfigEvents();
20452045

2046-
if (mType == DIRECT) {
2047-
activeTrack.clear();
2048-
}
2049-
20502046
mixerStatus = MIXER_IDLE;
20512047
{ // scope for mLock
20522048

@@ -2138,10 +2134,6 @@ if (mType == MIXER) {
21382134
lockEffectChains_l(effectChains);
21392135
}
21402136

2141-
if (mType == DIRECT) {
2142-
// For DirectOutputThread, this test is equivalent to "activeTrack != 0"
2143-
}
2144-
21452137
if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
21462138
threadLoop_mix();
21472139
} else {
@@ -2196,10 +2188,6 @@ if (mType == MIXER) {
21962188
// same lock.
21972189
tracksToRemove.clear();
21982190

2199-
// FIXME merge these
2200-
if (mType == DIRECT) {
2201-
activeTrack.clear();
2202-
}
22032191
// FIXME I don't understand the need for this here;
22042192
// it was in the original code but maybe the
22052193
// assignment in saveOutputTracks() makes this unnecessary?
@@ -2918,7 +2906,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
29182906

29192907
// reset retry count
29202908
track->mRetryCount = kMaxTrackRetriesDirect;
2921-
activeTrack = t;
2909+
mActiveTrack = t;
29222910
mixerStatus_ = MIXER_TRACKS_READY;
29232911
} else {
29242912
//ALOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
@@ -2968,18 +2956,19 @@ void AudioFlinger::DirectOutputThread::threadLoop_mix()
29682956
// output audio to hardware
29692957
while (frameCount) {
29702958
buffer.frameCount = frameCount;
2971-
activeTrack->getNextBuffer(&buffer);
2959+
mActiveTrack->getNextBuffer(&buffer);
29722960
if (CC_UNLIKELY(buffer.raw == NULL)) {
29732961
memset(curBuf, 0, frameCount * mFrameSize);
29742962
break;
29752963
}
29762964
memcpy(curBuf, buffer.raw, buffer.frameCount * mFrameSize);
29772965
frameCount -= buffer.frameCount;
29782966
curBuf += buffer.frameCount * mFrameSize;
2979-
activeTrack->releaseBuffer(&buffer);
2967+
mActiveTrack->releaseBuffer(&buffer);
29802968
}
29812969
sleepTime = 0;
29822970
standbyTime = systemTime() + standbyDelay;
2971+
mActiveTrack.clear();
29832972
applyVolume();
29842973
}
29852974

services/audioflinger/AudioFlinger.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,6 @@ class AudioFlinger :
973973
mixer_state mPrevMixerStatus; // previous status returned by prepareTracks_l()
974974
// DIRECT only
975975
nsecs_t standbyDelay;
976-
// activeTrack was local to the while !exitingPending loop
977-
sp<Track> activeTrack;
978976
// DUPLICATING only
979977
uint32_t writeFrames;
980978
};
@@ -1046,6 +1044,9 @@ class AudioFlinger :
10461044

10471045
private:
10481046
void applyVolume(); // FIXME inline into threadLoop_mix()
1047+
1048+
// prepareTracks_l() tells threadLoop_mix() the name of the single active track
1049+
sp<Track> mActiveTrack;
10491050
};
10501051

10511052
class DuplicatingThread : public MixerThread {

0 commit comments

Comments
 (0)