Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: media/audio/virtual_audio_input_stream_unittest.cc

Issue 11962008: Fix TSAN-detected data race: Sync with audio thread before accessing output_streams_ in unit test c… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <list> 5 #include <list>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 void Close() { 156 void Close() {
157 ASSERT_TRUE(!!stream_); 157 ASSERT_TRUE(!!stream_);
158 stream_->Close(); 158 stream_->Close();
159 stream_ = NULL; 159 stream_ = NULL;
160 closed_stream_.Signal(); 160 closed_stream_.Signal();
161 } 161 }
162 162
163 void WaitForDataPulls() { 163 void WaitForDataPulls() {
164 // Wait until audio thread is idle before calling output_streams_.size().
165 SyncWithAudioThread();
166
164 const int count = output_streams_.size(); 167 const int count = output_streams_.size();
165 for (int i = 0; i < count; ++i) { 168 for (int i = 0; i < count; ++i) {
166 source_.WaitForDataPulls(); 169 source_.WaitForDataPulls();
167 } 170 }
168 } 171 }
169 172
170 void WaitForDataPushes() { 173 void WaitForDataPushes() {
171 input_callback_.WaitForDataPushes(); 174 input_callback_.WaitForDataPushes();
172 } 175 }
173 176
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 RUN_ON_AUDIO_THREAD(Stop); 387 RUN_ON_AUDIO_THREAD(Stop);
385 RUN_ON_AUDIO_THREAD(Close); 388 RUN_ON_AUDIO_THREAD(Close);
386 WaitUntilClosed(); 389 WaitUntilClosed();
387 WaitForDataPulls(); 390 WaitForDataPulls();
388 for (int i = 0; i < kNumOutputs; ++i) { 391 for (int i = 0; i < kNumOutputs; ++i) {
389 RUN_ON_AUDIO_THREAD(StopAndCloseOneOutputStream); 392 RUN_ON_AUDIO_THREAD(StopAndCloseOneOutputStream);
390 } 393 }
391 } 394 }
392 395
393 } // namespace media 396 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698