OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/audio_modem/audio_recorder_impl.h" | 5 #include "components/audio_modem/audio_recorder_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { | 193 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { |
194 LOG(ERROR) << "Error during sound recording."; | 194 LOG(ERROR) << "Error during sound recording."; |
195 media::AudioManager::Get()->GetTaskRunner()->PostTask( | 195 media::AudioManager::Get()->GetTaskRunner()->PostTask( |
196 FROM_HERE, | 196 FROM_HERE, |
197 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, | 197 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, |
198 base::Unretained(this))); | 198 base::Unretained(this))); |
199 } | 199 } |
200 | 200 |
| 201 void AudioRecorderImpl::FlushAudioLoopForTesting() { |
| 202 if (media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()) |
| 203 return; |
| 204 |
| 205 // Queue task on the audio thread, when it is executed, that means we've |
| 206 // successfully executed all the tasks before us. |
| 207 base::RunLoop rl; |
| 208 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( |
| 209 FROM_HERE, |
| 210 base::Bind( |
| 211 base::IgnoreResult(&AudioRecorderImpl::FlushAudioLoopForTesting), |
| 212 base::Unretained(this)), |
| 213 rl.QuitClosure()); |
| 214 rl.Run(); |
| 215 } |
| 216 |
201 } // namespace audio_modem | 217 } // namespace audio_modem |
OLD | NEW |