[tsan] Guard audio_device_pulse_linux members from concurrent access.

This CL also fixes data races caused by tests themselves.

TBR= henrika@webrtc.org

Bug: webrtc:9751
Change-Id: Ie7c785b27142fd465f5b4dc9fb0628bd7274f1d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146600
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Yves Gerey <yvesg@google.com>
Cr-Commit-Position: refs/heads/master@{#28829}
This commit is contained in:
Yves Gerey
2019-07-22 21:15:22 +02:00
committed by Commit Bot
parent 1691e88584
commit 412282acf9
3 changed files with 16 additions and 7 deletions

View File

@ -871,8 +871,11 @@ int32_t AudioDeviceLinuxPulse::InitPlayout() {
playSampleSpec.rate = sample_rate_hz_;
// Create a new play stream
_playStream =
LATE(pa_stream_new)(_paContext, "playStream", &playSampleSpec, NULL);
{
rtc::CritScope lock(&_critSect);
_playStream =
LATE(pa_stream_new)(_paContext, "playStream", &playSampleSpec, NULL);
}
if (!_playStream) {
RTC_LOG(LS_ERROR) << "failed to create play stream, err="
@ -941,8 +944,11 @@ int32_t AudioDeviceLinuxPulse::InitPlayout() {
LATE(pa_stream_set_state_callback)(_playStream, PaStreamStateCallback, this);
// Mark playout side as initialized
_playIsInitialized = true;
_sndCardPlayDelay = 0;
{
rtc::CritScope lock(&_critSect);
_playIsInitialized = true;
_sndCardPlayDelay = 0;
}
return 0;
}