Fixes thread-safety-analysis warnings for Windows ADM.

Now using attribute to ensure that we avoid error like these when bulding with -Wthread-safety-analysis:
error: mutex '_critSect' is still held at the end of function [-Werror,-Wthread-safety-analysis]

RTC_NO_THREAD_SAFETY_ANALYSIS is an attribute on functions or methods, which turns off thread safety
checking for that method. It provides an escape hatch for functions which are either
(1) deliberately thread-unsafe, or
(2) are thread-safe, but too complicated for the analysis to understand.

Bug: webrtc:9202
Change-Id: Ie332bca7eb7eb535ed965de5ddc42872c4f30602
Reviewed-on: https://webrtc-review.googlesource.com/76562
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23221}
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index 8465a42..6f0aeb5 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -33,10 +33,6 @@
       "-Wno-microsoft-goto",
       "-Wno-reorder",
       "-Wno-shift-overflow",
-
-      # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6265
-      # for -Wno-thread-safety-analysis
-      "-Wno-thread-safety-analysis",
     ]
   }
 }
diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc
index 4e17ba7..9476f31 100644
--- a/modules/audio_device/win/audio_device_core_win.cc
+++ b/modules/audio_device/win/audio_device_core_win.cc
@@ -40,6 +40,7 @@
 
 #include "rtc_base/logging.h"
 #include "rtc_base/platform_thread.h"
+#include "rtc_base/thread_annotations.h"
 #include "system_wrappers/include/sleep.h"
 
 // Macro that calls a COM method returning HRESULT value.
@@ -3399,6 +3400,14 @@
   return 0;
 }
 
+void AudioDeviceWindowsCore::_Lock() RTC_NO_THREAD_SAFETY_ANALYSIS {
+  _critSect.Enter();
+}
+
+void AudioDeviceWindowsCore::_UnLock() RTC_NO_THREAD_SAFETY_ANALYSIS {
+  _critSect.Leave();
+}
+
 int AudioDeviceWindowsCore::SetDMOProperties() {
   HRESULT hr = S_OK;
   assert(_dmo != NULL);
diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h
index 317d034..1a0123e 100644
--- a/modules/audio_device/win/audio_device_core_win.h
+++ b/modules/audio_device/win/audio_device_core_win.h
@@ -201,8 +201,8 @@
     static DWORD WINAPI WSAPIRenderThread(LPVOID context);
     DWORD DoRenderThread();
 
-    void _Lock() { _critSect.Enter(); };
-    void _UnLock() { _critSect.Leave(); };
+    void _Lock();
+    void _UnLock();
 
     int SetDMOProperties();