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

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

Issue 12611030: Remove unused parameter to OnError() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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 (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_output_controller.h" 5 #include "media/audio/audio_output_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (state_ == kClosed) 112 if (state_ == kClosed)
113 return; 113 return;
114 114
115 DoStopCloseAndClearStream(); // Calls RemoveOutputDeviceChangeListener(). 115 DoStopCloseAndClearStream(); // Calls RemoveOutputDeviceChangeListener().
116 DCHECK_EQ(kEmpty, state_); 116 DCHECK_EQ(kEmpty, state_);
117 117
118 stream_ = diverting_to_stream_ ? diverting_to_stream_ : 118 stream_ = diverting_to_stream_ ? diverting_to_stream_ :
119 audio_manager_->MakeAudioOutputStreamProxy(params_); 119 audio_manager_->MakeAudioOutputStreamProxy(params_);
120 if (!stream_) { 120 if (!stream_) {
121 state_ = kError; 121 state_ = kError;
122 122 handler_->OnError();
123 // TODO(hclam): Define error types.
124 handler_->OnError(0);
125 return; 123 return;
126 } 124 }
127 125
128 if (!stream_->Open()) { 126 if (!stream_->Open()) {
129 DoStopCloseAndClearStream(); 127 DoStopCloseAndClearStream();
130 state_ = kError; 128 state_ = kError;
131 129 handler_->OnError();
132 // TODO(hclam): Define error types.
133 handler_->OnError(0);
134 return; 130 return;
135 } 131 }
136 132
137 // Everything started okay, so re-register for state change callbacks if 133 // Everything started okay, so re-register for state change callbacks if
138 // stream_ was created via AudioManager. 134 // stream_ was created via AudioManager.
139 if (stream_ != diverting_to_stream_) 135 if (stream_ != diverting_to_stream_)
140 audio_manager_->AddOutputDeviceChangeListener(this); 136 audio_manager_->AddOutputDeviceChangeListener(this);
141 137
142 // We have successfully opened the stream. Set the initial volume. 138 // We have successfully opened the stream. Set the initial volume.
143 stream_->SetVolume(volume_); 139 stream_->SetVolume(volume_);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 case kStarting: 267 case kStarting:
272 case kPlaying: 268 case kPlaying:
273 case kPaused: 269 case kPaused:
274 stream_->SetVolume(volume_); 270 stream_->SetVolume(volume_);
275 break; 271 break;
276 default: 272 default:
277 return; 273 return;
278 } 274 }
279 } 275 }
280 276
281 void AudioOutputController::DoReportError(int code) { 277 void AudioOutputController::DoReportError() {
282 DCHECK(message_loop_->BelongsToCurrentThread()); 278 DCHECK(message_loop_->BelongsToCurrentThread());
283 if (state_ != kClosed) 279 if (state_ != kClosed)
284 handler_->OnError(code); 280 handler_->OnError();
285 } 281 }
286 282
287 int AudioOutputController::OnMoreData(AudioBus* dest, 283 int AudioOutputController::OnMoreData(AudioBus* dest,
288 AudioBuffersState buffers_state) { 284 AudioBuffersState buffers_state) {
289 return OnMoreIOData(NULL, dest, buffers_state); 285 return OnMoreIOData(NULL, dest, buffers_state);
290 } 286 }
291 287
292 int AudioOutputController::OnMoreIOData(AudioBus* source, 288 int AudioOutputController::OnMoreIOData(AudioBus* source,
293 AudioBus* dest, 289 AudioBus* dest,
294 AudioBuffersState buffers_state) { 290 AudioBuffersState buffers_state) {
(...skipping 26 matching lines...) Expand all
321 // Wait for up to 683ms for DataReady(). 683ms was chosen because it's larger 317 // Wait for up to 683ms for DataReady(). 683ms was chosen because it's larger
322 // than the playback time of the WaveOut buffer size using the minimum 318 // than the playback time of the WaveOut buffer size using the minimum
323 // supported sample rate: 2048 / 3000 = ~683ms. 319 // supported sample rate: 2048 / 3000 = ~683ms.
324 const base::TimeDelta kMaxWait = base::TimeDelta::FromMilliseconds(683); 320 const base::TimeDelta kMaxWait = base::TimeDelta::FromMilliseconds(683);
325 while (!sync_reader_->DataReady() && 321 while (!sync_reader_->DataReady() &&
326 ((base::Time::Now() - start) < kMaxWait)) { 322 ((base::Time::Now() - start) < kMaxWait)) {
327 base::PlatformThread::YieldCurrentThread(); 323 base::PlatformThread::YieldCurrentThread();
328 } 324 }
329 } 325 }
330 326
331 void AudioOutputController::OnError(AudioOutputStream* stream, int code) { 327 void AudioOutputController::OnError(AudioOutputStream* stream) {
332 // Handle error on the audio controller thread. 328 // Handle error on the audio controller thread.
333 message_loop_->PostTask(FROM_HERE, base::Bind( 329 message_loop_->PostTask(FROM_HERE, base::Bind(
334 &AudioOutputController::DoReportError, this, code)); 330 &AudioOutputController::DoReportError, this));
335 } 331 }
336 332
337 void AudioOutputController::DoStopCloseAndClearStream() { 333 void AudioOutputController::DoStopCloseAndClearStream() {
338 DCHECK(message_loop_->BelongsToCurrentThread()); 334 DCHECK(message_loop_->BelongsToCurrentThread());
339 335
340 // Allow calling unconditionally and bail if we don't have a stream_ to close. 336 // Allow calling unconditionally and bail if we don't have a stream_ to close.
341 if (stream_) { 337 if (stream_) {
342 // De-register from state change callbacks if stream_ was created via 338 // De-register from state change callbacks if stream_ was created via
343 // AudioManager. 339 // AudioManager.
344 if (stream_ != diverting_to_stream_) 340 if (stream_ != diverting_to_stream_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); 425 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_));
430 base::AtomicRefCountInc(&num_allowed_io_); 426 base::AtomicRefCountInc(&num_allowed_io_);
431 } 427 }
432 428
433 void AudioOutputController::DisallowEntryToOnMoreIOData() { 429 void AudioOutputController::DisallowEntryToOnMoreIOData() {
434 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); 430 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_);
435 DCHECK(is_zero); 431 DCHECK(is_zero);
436 } 432 }
437 433
438 } // namespace media 434 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698