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

Side by Side Diff: components/audio_modem/audio_recorder_impl.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 Created 4 years, 8 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
OLDNEW
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
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
217 } // namespace audio_modem 201 } // namespace audio_modem
OLDNEW
« no previous file with comments | « components/audio_modem/audio_recorder_impl.h ('k') | components/audio_modem/audio_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698