AudioPolicyService InputDesc minor cleanup
Add a non-default constructor to set the mSessionId, and make mSessionId const.
Remove explicit clear on mEffects - it is automatically cleared by the destructor.
AudioPolicyService::setPreProcessorEnabled:
- parameter is const *
- use an alias instead of making a Vector copy
Destructor doesn't need to be virtual since there are no subclasses.
Change-Id: Ibc3c3bea8259839430b1cf5356186c7d96f1082f
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 753b1d2..7487f4b 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -298,8 +298,7 @@
ssize_t idx = mInputs.indexOfKey(input);
InputDesc *inputDesc;
if (idx < 0) {
- inputDesc = new InputDesc();
- inputDesc->mSessionId = audioSession;
+ inputDesc = new InputDesc(audioSession);
mInputs.add(input, inputDesc);
} else {
inputDesc = mInputs.valueAt(idx);
@@ -358,7 +357,6 @@
}
InputDesc *inputDesc = mInputs.valueAt(index);
setPreProcessorEnabled(inputDesc, false);
- inputDesc->mEffects.clear();
delete inputDesc;
mInputs.removeItemsAt(index);
}
@@ -600,9 +598,9 @@
return NO_ERROR;
}
-void AudioPolicyService::setPreProcessorEnabled(InputDesc *inputDesc, bool enabled)
+void AudioPolicyService::setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled)
{
- Vector<sp<AudioEffect> > fxVector = inputDesc->mEffects;
+ const Vector<sp<AudioEffect> > &fxVector = inputDesc->mEffects;
for (size_t i = 0; i < fxVector.size(); i++) {
fxVector.itemAt(i)->setEnabled(enabled);
}