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

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

Issue 2521583003: Adds speculative CHECKs to diagnose AudioManager crashes. (Closed)
Patch Set: Created 4 years 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/macros.h" 10 #include "base/macros.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 base::string16 AudioManagerBase::GetAudioInputDeviceModel() { 101 base::string16 AudioManagerBase::GetAudioInputDeviceModel() {
102 return base::string16(); 102 return base::string16();
103 } 103 }
104 104
105 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream( 105 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream(
106 const AudioParameters& params, 106 const AudioParameters& params,
107 const std::string& device_id, 107 const std::string& device_id,
108 const LogCallback& log_callback) { 108 const LogCallback& log_callback) {
109 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 109 CHECK(GetTaskRunner()->BelongsToCurrentThread());
110 110
111 if (!params.IsValid()) { 111 if (!params.IsValid()) {
112 DLOG(ERROR) << "Audio parameters are invalid"; 112 DLOG(ERROR) << "Audio parameters are invalid";
113 return NULL; 113 return NULL;
114 } 114 }
115 115
116 // Limit the number of audio streams opened. This is to prevent using 116 // Limit the number of audio streams opened. This is to prevent using
117 // excessive resources for a large number of audio streams. More 117 // excessive resources for a large number of audio streams. More
118 // importantly it prevents instability on certain systems. 118 // importantly it prevents instability on certain systems.
119 // See bug: http://crbug.com/30242. 119 // See bug: http://crbug.com/30242.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ++num_output_streams_; 153 ++num_output_streams_;
154 } 154 }
155 155
156 return stream; 156 return stream;
157 } 157 }
158 158
159 AudioInputStream* AudioManagerBase::MakeAudioInputStream( 159 AudioInputStream* AudioManagerBase::MakeAudioInputStream(
160 const AudioParameters& params, 160 const AudioParameters& params,
161 const std::string& device_id, 161 const std::string& device_id,
162 const LogCallback& log_callback) { 162 const LogCallback& log_callback) {
163 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 163 CHECK(GetTaskRunner()->BelongsToCurrentThread());
164 164
165 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || 165 if (!params.IsValid() || (params.channels() > kMaxInputChannels) ||
166 device_id.empty()) { 166 device_id.empty()) {
167 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; 167 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id;
168 return NULL; 168 return NULL;
169 } 169 }
170 170
171 if (input_stream_count() >= max_num_input_streams_) { 171 if (input_stream_count() >= max_num_input_streams_) {
172 DLOG(ERROR) << "Number of opened input audio streams " 172 DLOG(ERROR) << "Number of opened input audio streams "
173 << input_stream_count() << " exceed the max allowed number " 173 << input_stream_count() << " exceed the max allowed number "
(...skipping 23 matching lines...) Expand all
197 if (stream) { 197 if (stream) {
198 input_streams_.insert(stream); 198 input_streams_.insert(stream);
199 } 199 }
200 200
201 return stream; 201 return stream;
202 } 202 }
203 203
204 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( 204 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
205 const AudioParameters& params, 205 const AudioParameters& params,
206 const std::string& device_id) { 206 const std::string& device_id) {
207 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 207 CHECK(GetTaskRunner()->BelongsToCurrentThread());
208 208
209 // If the caller supplied an empty device id to select the default device, 209 // If the caller supplied an empty device id to select the default device,
210 // we fetch the actual device id of the default device so that the lookup 210 // we fetch the actual device id of the default device so that the lookup
211 // will find the correct device regardless of whether it was opened as 211 // will find the correct device regardless of whether it was opened as
212 // "default" or via the specific id. 212 // "default" or via the specific id.
213 // NOTE: Implementations that don't yet support opening non-default output 213 // NOTE: Implementations that don't yet support opening non-default output
214 // devices may return an empty string from GetDefaultOutputDeviceID(). 214 // devices may return an empty string from GetDefaultOutputDeviceID().
215 std::string output_device_id = 215 std::string output_device_id =
216 AudioDeviceDescription::IsDefaultDevice(device_id) 216 AudioDeviceDescription::IsDefaultDevice(device_id)
217 ? GetDefaultOutputDeviceID() 217 ? GetDefaultOutputDeviceID()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 void AudioManagerBase::GetAudioInputDeviceNames( 280 void AudioManagerBase::GetAudioInputDeviceNames(
281 AudioDeviceNames* device_names) { 281 AudioDeviceNames* device_names) {
282 } 282 }
283 283
284 void AudioManagerBase::GetAudioOutputDeviceNames( 284 void AudioManagerBase::GetAudioOutputDeviceNames(
285 AudioDeviceNames* device_names) { 285 AudioDeviceNames* device_names) {
286 } 286 }
287 287
288 void AudioManagerBase::ReleaseOutputStream(AudioOutputStream* stream) { 288 void AudioManagerBase::ReleaseOutputStream(AudioOutputStream* stream) {
289 CHECK(GetTaskRunner()->BelongsToCurrentThread());
289 DCHECK(stream); 290 DCHECK(stream);
290 CHECK_GT(num_output_streams_, 0); 291 CHECK_GT(num_output_streams_, 0);
291 // TODO(xians) : Have a clearer destruction path for the AudioOutputStream. 292 // TODO(xians) : Have a clearer destruction path for the AudioOutputStream.
292 // For example, pass the ownership to AudioManager so it can delete the 293 // For example, pass the ownership to AudioManager so it can delete the
293 // streams. 294 // streams.
294 --num_output_streams_; 295 --num_output_streams_;
295 delete stream; 296 delete stream;
296 } 297 }
297 298
298 void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { 299 void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) {
300 CHECK(GetTaskRunner()->BelongsToCurrentThread());
299 DCHECK(stream); 301 DCHECK(stream);
300 // TODO(xians) : Have a clearer destruction path for the AudioInputStream. 302 // TODO(xians) : Have a clearer destruction path for the AudioInputStream.
301 CHECK_EQ(1u, input_streams_.erase(stream)); 303 CHECK_EQ(1u, input_streams_.erase(stream));
302 delete stream; 304 delete stream;
303 } 305 }
304 306
305 void AudioManagerBase::Shutdown() { 307 void AudioManagerBase::Shutdown() {
306 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 308 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
307 // Close all output streams. 309 // Close all output streams.
308 while (!output_dispatchers_.empty()) { 310 while (!output_dispatchers_.empty()) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 404
403 return 0; 405 return 0;
404 } 406 }
405 407
406 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( 408 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
407 AudioLogFactory::AudioComponent component) { 409 AudioLogFactory::AudioComponent component) {
408 return audio_log_factory_->CreateAudioLog(component); 410 return audio_log_factory_->CreateAudioLog(component);
409 } 411 }
410 412
411 } // 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