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}
This commit is contained in:
henrika 2018-05-14 17:55:06 +02:00 committed by Commit Bot
parent 858c4d70cd
commit 52cab50c22
3 changed files with 11 additions and 6 deletions

View File

@ -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",
]
}
}

View File

@ -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);

View File

@ -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();