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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 1376313002: Check the current thread in AudioManagerBase::MakeAudio{Output,Input}Stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against ToT Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Lazily start the worker thread. 131 // Lazily start the worker thread.
132 if (!audio_thread_.IsRunning()) 132 if (!audio_thread_.IsRunning())
133 CHECK(audio_thread_.Start()); 133 CHECK(audio_thread_.Start());
134 134
135 return audio_thread_.task_runner(); 135 return audio_thread_.task_runner();
136 } 136 }
137 137
138 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream( 138 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream(
139 const AudioParameters& params, 139 const AudioParameters& params,
140 const std::string& device_id) { 140 const std::string& device_id) {
141 // TODO(miu): Fix ~50 call points across several unit test modules to call 141 DCHECK(task_runner_->BelongsToCurrentThread());
142 // this method on the audio thread, then uncomment the following:
143 // DCHECK(task_runner_->BelongsToCurrentThread());
144 142
145 if (!params.IsValid()) { 143 if (!params.IsValid()) {
146 DLOG(ERROR) << "Audio parameters are invalid"; 144 DLOG(ERROR) << "Audio parameters are invalid";
147 return NULL; 145 return NULL;
148 } 146 }
149 147
150 // Limit the number of audio streams opened. This is to prevent using 148 // Limit the number of audio streams opened. This is to prevent using
151 // excessive resources for a large number of audio streams. More 149 // excessive resources for a large number of audio streams. More
152 // importantly it prevents instability on certain systems. 150 // importantly it prevents instability on certain systems.
153 // See bug: http://crbug.com/30242. 151 // See bug: http://crbug.com/30242.
(...skipping 26 matching lines...) Expand all
180 if (stream) { 178 if (stream) {
181 ++num_output_streams_; 179 ++num_output_streams_;
182 } 180 }
183 181
184 return stream; 182 return stream;
185 } 183 }
186 184
187 AudioInputStream* AudioManagerBase::MakeAudioInputStream( 185 AudioInputStream* AudioManagerBase::MakeAudioInputStream(
188 const AudioParameters& params, 186 const AudioParameters& params,
189 const std::string& device_id) { 187 const std::string& device_id) {
190 // TODO(miu): Fix ~20 call points across several unit test modules to call 188 DCHECK(task_runner_->BelongsToCurrentThread());
191 // this method on the audio thread, then uncomment the following:
192 // DCHECK(task_runner_->BelongsToCurrentThread());
193 189
194 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || 190 if (!params.IsValid() || (params.channels() > kMaxInputChannels) ||
195 device_id.empty()) { 191 device_id.empty()) {
196 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; 192 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id;
197 return NULL; 193 return NULL;
198 } 194 }
199 195
200 if (num_input_streams_ >= max_num_input_streams_) { 196 if (num_input_streams_ >= max_num_input_streams_) {
201 DLOG(ERROR) << "Number of opened input audio streams " 197 DLOG(ERROR) << "Number of opened input audio streams "
202 << num_input_streams_ 198 << num_input_streams_
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog( 404 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
409 AudioLogFactory::AudioComponent component) { 405 AudioLogFactory::AudioComponent component) {
410 return audio_log_factory_->CreateAudioLog(component); 406 return audio_log_factory_->CreateAudioLog(component);
411 } 407 }
412 408
413 void AudioManagerBase::SetHasKeyboardMic() { 409 void AudioManagerBase::SetHasKeyboardMic() {
414 NOTREACHED(); 410 NOTREACHED();
415 } 411 }
416 412
417 } // namespace media 413 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698