Skip to content

Commit fee5a86

Browse files
Justin HoAndroid (Google) Code Review
authored andcommitted
Merge "DO NOT MERGE Revert "AudioFlinger: mix track only when really ready (2)"" into ics-mr1
2 parents 5e5b57a + b918035 commit fee5a86

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ uint32_t AudioFlinger::PlaybackThread::activeSleepTimeUs()
18321832

18331833
AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
18341834
: PlaybackThread(audioFlinger, output, id, device),
1835-
mAudioMixer(0), mPrevMixerStatus(MIXER_IDLE)
1835+
mAudioMixer(0)
18361836
{
18371837
mType = ThreadBase::MIXER;
18381838
mAudioMixer = new AudioMixer(mFrameCount, mSampleRate);
@@ -1945,7 +1945,6 @@ bool AudioFlinger::MixerThread::threadLoop()
19451945
LOGV("MixerThread %p TID %d waking up\n", this, gettid());
19461946
acquireWakeLock_l();
19471947

1948-
mPrevMixerStatus = MIXER_IDLE;
19491948
if (mMasterMute == false) {
19501949
char value[PROPERTY_VALUE_MAX];
19511950
property_get("ro.audio.silent", value, "0");
@@ -2104,11 +2103,11 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
21042103
// make sure that we have enough frames to mix one full buffer.
21052104
// enforce this condition only once to enable draining the buffer in case the client
21062105
// app does not call stop() and relies on underrun to stop:
2107-
// hence the test on (mPrevMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
2106+
// hence the test on (track->mRetryCount >= kMaxTrackRetries) meaning the track was mixed
21082107
// during last round
21092108
uint32_t minFrames = 1;
21102109
if (!track->isStopped() && !track->isPausing() &&
2111-
(mPrevMixerStatus == MIXER_TRACKS_READY)) {
2110+
(track->mRetryCount >= kMaxTrackRetries)) {
21122111
if (t->sampleRate() == (int)mSampleRate) {
21132112
minFrames = mFrameCount;
21142113
} else {
@@ -2230,13 +2229,7 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
22302229

22312230
// reset retry count
22322231
track->mRetryCount = kMaxTrackRetries;
2233-
// If one track is ready, set the mixer ready if:
2234-
// - the mixer was not ready during previous round OR
2235-
// - no other track is not ready
2236-
if (mPrevMixerStatus != MIXER_TRACKS_READY ||
2237-
mixerStatus != MIXER_TRACKS_ENABLED) {
2238-
mixerStatus = MIXER_TRACKS_READY;
2239-
}
2232+
mixerStatus = MIXER_TRACKS_READY;
22402233
} else {
22412234
//LOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", track->name(), cblk->user, cblk->server, this);
22422235
if (track->isStopped()) {
@@ -2254,11 +2247,7 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
22542247
tracksToRemove->add(track);
22552248
// indicate to client process that the track was disabled because of underrun
22562249
android_atomic_or(CBLK_DISABLED_ON, &cblk->flags);
2257-
// If one track is not ready, mark the mixer also not ready if:
2258-
// - the mixer was ready during previous round OR
2259-
// - no other track is ready
2260-
} else if (mPrevMixerStatus == MIXER_TRACKS_READY ||
2261-
mixerStatus != MIXER_TRACKS_READY) {
2250+
} else if (mixerStatus != MIXER_TRACKS_READY) {
22622251
mixerStatus = MIXER_TRACKS_ENABLED;
22632252
}
22642253
}
@@ -2292,7 +2281,6 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
22922281
memset(mMixBuffer, 0, mFrameCount * mChannelCount * sizeof(int16_t));
22932282
}
22942283

2295-
mPrevMixerStatus = mixerStatus;
22962284
return mixerStatus;
22972285
}
22982286

@@ -3028,7 +3016,6 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
30283016
LOGV("DuplicatingThread %p TID %d waking up\n", this, gettid());
30293017
acquireWakeLock_l();
30303018

3031-
mPrevMixerStatus = MIXER_IDLE;
30323019
if (mMasterMute == false) {
30333020
char value[PROPERTY_VALUE_MAX];
30343021
property_get("ro.audio.silent", value, "0");

services/audioflinger/AudioFlinger.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,7 @@ class AudioFlinger :
836836
virtual uint32_t idleSleepTimeUs();
837837
virtual uint32_t suspendSleepTimeUs();
838838

839-
AudioMixer* mAudioMixer;
840-
uint32_t mPrevMixerStatus; // previous status (mixer_state) returned by
841-
// prepareTracks_l()
839+
AudioMixer* mAudioMixer;
842840
};
843841

844842
class DirectOutputThread : public PlaybackThread {

0 commit comments

Comments
 (0)