summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-03-06 11:28:04 -0800
committerGlenn Kasten <gkasten@google.com>2012-03-07 11:04:55 -0800
commit08d2c041940f80161a306304e18aa4a736cccf4a (patch)
treebea9d1165676a9b5fa873b8f358155449720acbc /services/audioflinger
parent9778bd1f33a28f3f403a93ba195121c3d03fb266 (diff)
downloadframeworks_base-08d2c041940f80161a306304e18aa4a736cccf4a.zip
frameworks_base-08d2c041940f80161a306304e18aa4a736cccf4a.tar.gz
frameworks_base-08d2c041940f80161a306304e18aa4a736cccf4a.tar.bz2
Isolate references to outputTracks/mOutputTracks
Move all references to DuplicatingThread::outputTracks and DuplicatingThread::mOutputTracks from the common threadLoop() into virtual methods. This allows them to be moved from PlaybackThread to DuplicatingThread, and to be marked private. Also use vector assignment to copy mOutputTracks to outputTracks. Change-Id: Ieb1cf1ad36b8a65143e61e6c92a65fb43427e5e2
Diffstat (limited to 'services/audioflinger')
-rw-r--r--services/audioflinger/AudioFlinger.cpp33
-rw-r--r--services/audioflinger/AudioFlinger.h10
2 files changed, 24 insertions, 19 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index fe068af..608fc71 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2074,17 +2074,7 @@ if (mType == DIRECT) {
}
-if (mType == DUPLICATING) {
-#if 0 // see earlier FIXME
- // Now that this is a field instead of local variable,
- // clear it so it is empty the first time through the loop,
- // and later an assignment could combine the clear with the loop below
- outputTracks.clear();
-#endif
- for (size_t i = 0; i < mOutputTracks.size(); i++) {
- outputTracks.add(mOutputTracks[i]);
- }
-}
+ saveOutputTracks();
// put audio hardware into standby after short delay
if (CC_UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
@@ -2101,9 +2091,7 @@ if (mType == DUPLICATING) {
// we're about to wait, flush the binder command buffer
IPCThreadState::self()->flushCommands();
-if (mType == DUPLICATING) {
- outputTracks.clear();
-}
+ clearOutputTracks();
if (exitPending()) break;
@@ -2212,9 +2200,10 @@ if (mType == MIXER) {
if (mType == DIRECT) {
activeTrack.clear();
}
-if (mType == DUPLICATING) {
- outputTracks.clear();
-}
+ // FIXME I don't understand the need for this here;
+ // it was in the original code but maybe the
+ // assignment in saveOutputTracks() makes this unnecessary?
+ clearOutputTracks();
// Effect chains will be actually deleted here if they were removed from
// mEffectChains list during mixing or effects processing
@@ -3168,6 +3157,16 @@ void AudioFlinger::DuplicatingThread::threadLoop_standby()
}
}
+void AudioFlinger::DuplicatingThread::saveOutputTracks()
+{
+ outputTracks = mOutputTracks;
+}
+
+void AudioFlinger::DuplicatingThread::clearOutputTracks()
+{
+ outputTracks.clear();
+}
+
void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread)
{
Mutex::Autolock _l(mLock);
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 8ca4f89..518a99c 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -920,6 +920,10 @@ public:
// Code snippets that are temporarily lifted up out of threadLoop() until the merge
void checkSilentMode_l();
+ // Non-trivial for DUPLICATING only
+ virtual void saveOutputTracks() { }
+ virtual void clearOutputTracks() { }
+
private:
friend class AudioFlinger;
@@ -972,9 +976,7 @@ public:
// activeTrack was local to the while !exitingPending loop
sp<Track> activeTrack;
// DUPLICATING only
- SortedVector < sp<OutputTrack> > outputTracks;
uint32_t writeFrames;
- SortedVector < sp<OutputTrack> > mOutputTracks;
};
class MixerThread : public PlaybackThread {
@@ -1070,9 +1072,13 @@ private:
// called from threadLoop, addOutputTrack, removeOutputTrack
virtual void updateWaitTime_l();
+ virtual void saveOutputTracks();
+ virtual void clearOutputTracks();
private:
uint32_t mWaitTimeMs;
+ SortedVector < sp<OutputTrack> > outputTracks;
+ SortedVector < sp<OutputTrack> > mOutputTracks;
};
PlaybackThread *checkPlaybackThread_l(audio_io_handle_t output) const;