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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
10 #include "media/audio/simple_sources.h" | 10 #include "media/audio/simple_sources.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 if (num_output_streams == 0 && num_streams_removed_per_round > 0) { | 78 if (num_output_streams == 0 && num_streams_removed_per_round > 0) { |
79 AudioOutputStream* output_stream = output_streams_.back(); | 79 AudioOutputStream* output_stream = output_streams_.back(); |
80 output_streams_.pop_back(); | 80 output_streams_.pop_back(); |
81 output_stream->Stop(); | 81 output_stream->Stop(); |
82 output_stream->Close(); | 82 output_stream->Close(); |
83 } | 83 } |
84 | 84 |
85 if (num_callback_iterations > 0) { | 85 if (num_callback_iterations > 0) { |
86 // Force the next callback to be immediate. | 86 // Force the next callback to be immediate. |
87 stream_->buffer_duration_ms_ = base::TimeDelta(); | 87 stream_->buffer_duration_ = base::TimeDelta(); |
88 audio_manager_->GetMessageLoop()->PostTask( | 88 audio_manager_->GetMessageLoop()->PostTask( |
89 FROM_HERE, base::Bind( | 89 FROM_HERE, base::Bind( |
90 &VirtualAudioInputStreamTest::AddStreamsAndDoCallbacks, | 90 &VirtualAudioInputStreamTest::AddStreamsAndDoCallbacks, |
91 base::Unretained(this), | 91 base::Unretained(this), |
92 0, | 92 0, |
93 --num_callback_iterations, | 93 --num_callback_iterations, |
94 num_streams_removed_per_round, | 94 num_streams_removed_per_round, |
95 num_expected_source_callbacks)); | 95 num_expected_source_callbacks)); |
96 } else { | 96 } else { |
97 // Finish the test. | 97 // Finish the test. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Start or stop half the streams. | 165 // Start or stop half the streams. |
166 for (int i = 0; i < num_output_streams / 2; ++i) { | 166 for (int i = 0; i < num_output_streams / 2; ++i) { |
167 if (num_callback_iterations % 2 != 0) | 167 if (num_callback_iterations % 2 != 0) |
168 output_streams_[i]->Stop(); | 168 output_streams_[i]->Stop(); |
169 else | 169 else |
170 output_streams_[i]->Start(&source_); | 170 output_streams_[i]->Start(&source_); |
171 } | 171 } |
172 | 172 |
173 if (num_callback_iterations > 0) { | 173 if (num_callback_iterations > 0) { |
174 // Force the next callback to be immediate. | 174 // Force the next callback to be immediate. |
175 stream_->buffer_duration_ms_ = base::TimeDelta::FromMilliseconds(0); | 175 stream_->buffer_duration_ = base::TimeDelta::FromMilliseconds(0); |
176 audio_manager_->GetMessageLoop()->PostTask( | 176 audio_manager_->GetMessageLoop()->PostTask( |
177 FROM_HERE, base::Bind( | 177 FROM_HERE, base::Bind( |
178 &VirtualAudioInputStreamTest::StartStopCallback, | 178 &VirtualAudioInputStreamTest::StartStopCallback, |
179 base::Unretained(this), | 179 base::Unretained(this), |
180 false, | 180 false, |
181 num_output_streams, | 181 num_output_streams, |
182 --num_callback_iterations, | 182 --num_callback_iterations, |
183 num_expected_source_callbacks)); | 183 num_expected_source_callbacks)); |
184 } else { | 184 } else { |
185 // Finish the test. | 185 // Finish the test. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 &VirtualAudioInputStreamTest::StartStopOnAudioThread, | 313 &VirtualAudioInputStreamTest::StartStopOnAudioThread, |
314 base::Unretained(this), | 314 base::Unretained(this), |
315 num_output_streams, | 315 num_output_streams, |
316 num_callback_iterations, | 316 num_callback_iterations, |
317 num_expected_source_callbacks)); | 317 num_expected_source_callbacks)); |
318 | 318 |
319 done_.Wait(); | 319 done_.Wait(); |
320 } | 320 } |
321 | 321 |
322 } // namespace media | 322 } // namespace media |
OLD | NEW |