Skip to content

Commit fcf2ac0

Browse files
committed
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
1 parent 21b4d6b commit fcf2ac0

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

services/audioflinger/AudioPolicyService.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
298298
ssize_t idx = mInputs.indexOfKey(input);
299299
InputDesc *inputDesc;
300300
if (idx < 0) {
301-
inputDesc = new InputDesc();
302-
inputDesc->mSessionId = audioSession;
301+
inputDesc = new InputDesc(audioSession);
303302
mInputs.add(input, inputDesc);
304303
} else {
305304
inputDesc = mInputs.valueAt(idx);
@@ -358,7 +357,6 @@ void AudioPolicyService::releaseInput(audio_io_handle_t input)
358357
}
359358
InputDesc *inputDesc = mInputs.valueAt(index);
360359
setPreProcessorEnabled(inputDesc, false);
361-
inputDesc->mEffects.clear();
362360
delete inputDesc;
363361
mInputs.removeItemsAt(index);
364362
}
@@ -600,9 +598,9 @@ status_t AudioPolicyService::dumpPermissionDenial(int fd)
600598
return NO_ERROR;
601599
}
602600

603-
void AudioPolicyService::setPreProcessorEnabled(InputDesc *inputDesc, bool enabled)
601+
void AudioPolicyService::setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled)
604602
{
605-
Vector<sp<AudioEffect> > fxVector = inputDesc->mEffects;
603+
const Vector<sp<AudioEffect> > &fxVector = inputDesc->mEffects;
606604
for (size_t i = 0; i < fxVector.size(); i++) {
607605
fxVector.itemAt(i)->setEnabled(enabled);
608606
}

services/audioflinger/AudioPolicyService.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ class AudioPolicyService :
279279

280280
class InputDesc {
281281
public:
282-
InputDesc() {}
283-
virtual ~InputDesc() {}
284-
int mSessionId;
282+
InputDesc(int session) : mSessionId(session) {}
283+
/*virtual*/ ~InputDesc() {}
284+
const int mSessionId;
285285
Vector< sp<AudioEffect> >mEffects;
286286
};
287287

288288
static const char * const kInputSourceNames[AUDIO_SOURCE_CNT -1];
289289

290-
void setPreProcessorEnabled(InputDesc *inputDesc, bool enabled);
290+
void setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled);
291291
status_t loadPreProcessorConfig(const char *path);
292292
status_t loadEffects(cnode *root, Vector <EffectDesc *>& effects);
293293
EffectDesc *loadEffect(cnode *root);

0 commit comments

Comments
 (0)