From 52cab50c22f01866f10d4bf2398a8d7cd3e9b8e5 Mon Sep 17 00:00:00 2001 From: henrika Date: Mon, 14 May 2018 17:55:06 +0200 Subject: [PATCH] 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 Commit-Queue: Henrik Andreassson Cr-Commit-Position: refs/heads/master@{#23221} --- modules/audio_device/BUILD.gn | 4 ---- modules/audio_device/win/audio_device_core_win.cc | 9 +++++++++ modules/audio_device/win/audio_device_core_win.h | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn index 8465a427c3..6f0aeb5e1b 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -33,10 +33,6 @@ config("audio_device_warnings_config") { "-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 4e17ba7b4a..9476f311b1 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 @@ int32_t AudioDeviceWindowsCore::EnableBuiltInAEC(bool enable) { 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 317d034d29..1a0123ec40 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 @@ private: // thread functions static DWORD WINAPI WSAPIRenderThread(LPVOID context); DWORD DoRenderThread(); - void _Lock() { _critSect.Enter(); }; - void _UnLock() { _critSect.Leave(); }; + void _Lock(); + void _UnLock(); int SetDMOProperties();