Merge changes from topic "audio-v5"

* changes:
  libaudiohal: move to Stream Metadata to common
  libaudiohal: Introduce support HAL V5 identical to V4
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index b0c9fda..85f5456 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -71,6 +71,12 @@
 
             status_t    getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones);
 
+    static  bool        checkServerLatencySupported(
+                                audio_format_t format, audio_input_flags_t flags) {
+                            return audio_is_linear_pcm(format)
+                                    && (flags & AUDIO_INPUT_FLAG_HW_AV_SYNC) == 0;
+                        }
+
 private:
     friend class AudioFlinger;  // for mState
 
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index cec0819..46e40c7 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -7562,7 +7562,7 @@
         (void)input->stream->dump(fd);
     }
 
-    const double latencyMs = audio_is_linear_pcm(mFormat)
+    const double latencyMs = RecordTrack::checkServerLatencySupported(mFormat, input->flags)
             ? - mTimestamp.getOutputServerLatencyMs(mSampleRate) : 0.;
     if (latencyMs != 0.) {
         dprintf(fd, "  NormalRecord latency ms: %.2lf\n", latencyMs);
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 91a3286..dd81c71 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1772,7 +1772,7 @@
         thread->mFastTrackAvail = false;
     } else {
         // TODO: only Normal Record has timestamps (Fast Record does not).
-        mServerLatencySupported = audio_is_linear_pcm(mFormat);
+        mServerLatencySupported = checkServerLatencySupported(mFormat, flags);
     }
 #ifdef TEE_SINK
     mTee.setId(std::string("_") + std::to_string(mThreadIoHandle)