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
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 == 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 @@
// 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 == 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::saveOutputTracks()
+{
+ outputTracks = mOutputTracks;
+}
+
+void AudioFlinger::DuplicatingThread::clearOutputTracks()
+{
+ outputTracks.clear();
+}
+
void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread)
{
Mutex::Autolock _l(mLock);