Close input streams for external devices immediately after probing

Input mix ports may have "max open count" set to "1" in the HAL
configuration, and this does not allow the APM to open multiple
input streams on them. This was not an issue in HIDL because
HIDL HALs did not enforce the stream count capping, it was
enforced on the APM side only.

Change 'checkInputForDevice' behavior so that it closes each
unused output immediately after opening and probing, instead
of opening many streams at once and then relying on
'checkCloseInputs' for closed unused ones.

Bug: 326211518
Test: atest audiopolicy_tests
Test: connect external device on Pixel, check for
      "reaches the max open count" HAL error logs
Change-Id: I2a9159509ba3a14824ebc4281dddfb0c687219f6
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 83597d8..137dccd 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -529,6 +529,7 @@
         void addOutput(audio_io_handle_t output, const sp<SwAudioOutputDescriptor>& outputDesc);
         void removeOutput(audio_io_handle_t output);
         void addInput(audio_io_handle_t input, const sp<AudioInputDescriptor>& inputDesc);
+        bool checkCloseInput(const sp<AudioInputDescriptor>& input);
 
         /**
          * @brief setOutputDevices change the route of the specified output.