audiopolicy: fix source client lifecycle

Upon startAudioSource -> connectAudioSource, the source client
is attached to the output.
Upon stopAudioSource -> disconnectAudioSource, the source client is
never removed.

As a result, if the same client is trying to call startAudioSource again,
asthe client is already attached, getClient will lead to bailing out in
connectAudioSource and the source will not be started.
The stopAudioSource if called would claim that the client refcount is already 0.

Any following call to start would fail again on outputDesc->start as invalid
as the profile fails on canStartNewIo.

This CL fixes this issue by removing the client source desc on disconnectAudioSource.

Bug: 133367802
Test: build & run
	    AudioPolicyEmulatorTests --gtest_filter=*AudioSourceEffectTest*
      multiple consecutive times.

Change-Id: I78370be248ff24cf4135d51f709d965c5bfae4e8
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
gugelfrei
François Gaffie 5 years ago committed by Eric Laurent
parent f9b3d532eb
commit 5592ee2685

@ -3924,6 +3924,8 @@ status_t AudioPolicyManager::connectAudioSource(const sp<SourceClientDescriptor>
if (status != NO_ERROR) {
mpClientInterface->releaseAudioPatch(sourceDesc->patchDesc()->mAfPatchHandle, 0);
outputDesc->removeClient(sourceDesc->portId());
outputDesc->stop();
return status;
}
sourceDesc->setSwOutput(outputDesc);
@ -4188,6 +4190,7 @@ status_t AudioPolicyManager::disconnectAudioSource(const sp<SourceClientDescript
if (status == NO_ERROR) {
swOutputDesc->stop();
}
swOutputDesc->removeClient(sourceDesc->portId());
mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
} else {
sp<HwAudioOutputDescriptor> hwOutputDesc = sourceDesc->hwOutput().promote();

Loading…
Cancel
Save