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

Side by Side Diff: components/audio_modem/audio_player_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_player_impl.h" 5 #include "components/audio_modem/audio_player_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/run_loop.h"
14 #include "components/audio_modem/public/audio_modem_types.h" 13 #include "components/audio_modem/public/audio_modem_types.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "media/audio/audio_manager.h" 14 #include "media/audio/audio_manager.h"
17 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
18 #include "media/base/audio_bus.h" 16 #include "media/base/audio_bus.h"
19 17
20 namespace { 18 namespace {
21 19
22 const int kDefaultFrameCount = 1024; 20 const int kDefaultFrameCount = 1024;
23 const double kOutputVolumePercent = 1.0f; 21 const double kOutputVolumePercent = 1.0f;
24 22
25 } // namespace 23 } // namespace
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 153 }
156 154
157 void AudioPlayerImpl::OnError(media::AudioOutputStream* /* stream */) { 155 void AudioPlayerImpl::OnError(media::AudioOutputStream* /* stream */) {
158 LOG(ERROR) << "Error during system sound reproduction."; 156 LOG(ERROR) << "Error during system sound reproduction.";
159 media::AudioManager::Get()->GetTaskRunner()->PostTask( 157 media::AudioManager::Get()->GetTaskRunner()->PostTask(
160 FROM_HERE, 158 FROM_HERE,
161 base::Bind(&AudioPlayerImpl::StopAndCloseOnAudioThread, 159 base::Bind(&AudioPlayerImpl::StopAndCloseOnAudioThread,
162 base::Unretained(this))); 160 base::Unretained(this)));
163 } 161 }
164 162
165 void AudioPlayerImpl::FlushAudioLoopForTesting() {
166 if (media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread())
167 return;
168
169 // Queue task on the audio thread, when it is executed, that means we've
170 // successfully executed all the tasks before us.
171 base::RunLoop rl;
172 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply(
173 FROM_HERE,
174 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting),
175 base::Unretained(this)),
176 rl.QuitClosure());
177 rl.Run();
178 }
179
180 } // namespace audio_modem 163 } // namespace audio_modem
OLDNEW
« no previous file with comments | « components/audio_modem/audio_player_impl.h ('k') | components/audio_modem/audio_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698