Use index mask when there is no valid input mask from output mask.

When creating PatchRecord, there can be no input channel mask equivalent
to output channel mask. In that case, use index mask instead given there
is already a proper output channel mask.

Bug: 245793724
Test: repo steps in bug
Test: atest audiopolicy_tests AudioPlaybackCaptureTest
Change-Id: Ie6b5d80899a7eeea1fcb88fcdf8cd50bc1a97321
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 7f0fc1f..9a0ba1a 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3735,6 +3735,12 @@
 
         using namespace std::chrono_literals;
         auto inChannelMask = audio_channel_mask_out_to_in(track->channelMask());
+        if (inChannelMask == AUDIO_CHANNEL_INVALID) {
+            // The downstream PatchTrack has the proper output channel mask,
+            // so if there is no input channel mask equivalent, we can just
+            // use an index mask here to create the PatchRecord.
+            inChannelMask = audio_channel_mask_out_to_in_index_mask(track->channelMask());
+        }
         sp patchRecord = new RecordThread::PatchRecord(nullptr /* thread */,
                                                        track->sampleRate(),
                                                        inChannelMask,