Release audio patch just after it was created in case no waiting caller

3s timeout (error -110, TIMED_OUT) might happen during audio patch
creation in AudioCommandThread. In such case the caller (e.g. binder
transaction: AudioPolicyManager::startAudioSource() ->
connectAudioSource()) gets no valid handle and quits with error, while
AudioCommandThread keeps trying to finalize patch create.
In case AudioCommandThread succeeds (after 3s timeout), the handle
becomes lost while resources allocated by audio-hal during patch create
remain busy so next tries of creating audio patches fail (error -12,
NO_MEMORY).

To prevent from audio-hal resources leakage, release the audio patch
that nobody is waiting for just after it was created.

Test: Manual
Bug: https://partnerissuetracker.corp.google.com/issues/356095582
Change-Id: I7bee96541b03299d0f8cbd9d724ae217b9a66bb3
1 file changed