audiopolicy: Fix ompilation errors with AOSP refresh

- Update GetOutputDevice API to inline with AOSP refresh

Change-Id: Ia898b25e1d547052a50d691d9550831c6c8d064a
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 85932ac..6cc8420 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1427,10 +1427,11 @@
         audio_devices_t device,
         audio_session_t session,
         audio_stream_type_t stream,
+        audio_io_handle_t originalOutput,
         const audio_config_t *config,
         audio_output_flags_t *flags)
 {
-    audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
+    audio_io_handle_t output = originalOutput;
     status_t status;
 
     if (stream < AUDIO_STREAM_MIN || stream >= AUDIO_STREAM_CNT) {
@@ -1770,29 +1771,30 @@
             goto non_direct_output;
         }
 
-
-        // if multiple concurrent offload decode is supported
-        // do no check for reuse and also don't close previous output if its offload
-        // previous output will be closed during track destruction
-        if (!(property_get_bool("vendor.audio.offload.multiple.enabled", false) &&
+        if ((*flags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) == 0 || output != AUDIO_IO_HANDLE_NONE) {
+            // if multiple concurrent offload decode is supported
+            // do no check for reuse and also don't close previous output if its offload
+            // previous output will be closed during track destruction
+            if (!(property_get_bool("vendor.audio.offload.multiple.enabled", false) &&
                 ((*flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0))) {
-        for (size_t i = 0; i < mOutputs.size(); i++) {
-            sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
-            if (!desc->isDuplicated() && (profile == desc->mProfile)) {
-                // reuse direct output if currently open by the same client
-                // and configured with same parameters
-                if ((config->sample_rate == desc->mSamplingRate) &&
-                    audio_formats_match(config->format, desc->mFormat) &&
-                    (config->channel_mask == desc->mChannelMask) &&
-                    (session == desc->mDirectClientSession)) {
-                    desc->mDirectOpenCount++;
-                    ALOGV("getOutputForDevice() reusing direct output %d for session %d",
-                        mOutputs.keyAt(i), session);
-                    return mOutputs.keyAt(i);
+                for (size_t i = 0; i < mOutputs.size(); i++) {
+                   sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
+                   if (!desc->isDuplicated() && (profile == desc->mProfile)) {
+                        // reuse direct output if currently open by the same client
+                        // and configured with same parameters
+                        if ((config->sample_rate == desc->mSamplingRate) &&
+                            audio_formats_match(config->format, desc->mFormat) &&
+                            (config->channel_mask == desc->mChannelMask) &&
+                            (session == desc->mDirectClientSession)) {
+                            desc->mDirectOpenCount++;
+                            ALOGV("getOutputForDevice() reusing direct output %d for session %d",
+                                   mOutputs.keyAt(i), session);
+                           return mOutputs.keyAt(i);
+                        }
+                    }
                 }
             }
-       }
-       }
+        }
 #if 0 // TODO: Handle direct PCM fallback case
                 if (*flags == AUDIO_OUTPUT_FLAG_DIRECT &&
                     direct_pcm_already_in_use == true &&
@@ -1851,7 +1853,7 @@
 
     // A request for HW A/V sync cannot fallback to a mixed output because time
     // stamps are embedded in audio data
-    if ((*flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC) != 0) {
+    if ((*flags & (AUDIO_OUTPUT_FLAG_HW_AV_SYNC | AUDIO_OUTPUT_FLAG_MMAP_NOIRQ)) != 0) {
         return AUDIO_IO_HANDLE_NONE;
     }
 
diff --git a/policy_hal/AudioPolicyManager.h b/policy_hal/AudioPolicyManager.h
index 9b80558..17101b0 100644
--- a/policy_hal/AudioPolicyManager.h
+++ b/policy_hal/AudioPolicyManager.h
@@ -171,6 +171,7 @@
                 audio_devices_t device,
                 audio_session_t session,
                 audio_stream_type_t stream,
+                audio_io_handle_t originalOutput,
                 const audio_config_t *config,
                 audio_output_flags_t *flags);