OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |