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

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: Fix nits + rebase 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
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/audio/audio_output_controller_unittest.cc » ('j') | 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_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (state_ == kClosed) 100 if (state_ == kClosed)
101 return; 101 return;
102 102
103 DoStopCloseAndClearStream(); // Calls RemoveOutputDeviceChangeListener(). 103 DoStopCloseAndClearStream(); // Calls RemoveOutputDeviceChangeListener().
104 DCHECK_EQ(kEmpty, state_); 104 DCHECK_EQ(kEmpty, state_);
105 105
106 stream_ = diverting_to_stream_ ? diverting_to_stream_ : 106 stream_ = diverting_to_stream_ ? diverting_to_stream_ :
107 audio_manager_->MakeAudioOutputStreamProxy(params_); 107 audio_manager_->MakeAudioOutputStreamProxy(params_);
108 if (!stream_) { 108 if (!stream_) {
109 state_ = kError; 109 state_ = kError;
110 110 handler_->OnError(this);
111 // TODO(hclam): Define error types.
112 handler_->OnError(this, 0);
113 return; 111 return;
114 } 112 }
115 113
116 if (!stream_->Open()) { 114 if (!stream_->Open()) {
117 DoStopCloseAndClearStream(); 115 DoStopCloseAndClearStream();
118 state_ = kError; 116 state_ = kError;
119 117 handler_->OnError(this);
120 // TODO(hclam): Define error types.
121 handler_->OnError(this, 0);
122 return; 118 return;
123 } 119 }
124 120
125 // Everything started okay, so re-register for state change callbacks if 121 // Everything started okay, so re-register for state change callbacks if
126 // stream_ was created via AudioManager. 122 // stream_ was created via AudioManager.
127 if (stream_ != diverting_to_stream_) 123 if (stream_ != diverting_to_stream_)
128 audio_manager_->AddOutputDeviceChangeListener(this); 124 audio_manager_->AddOutputDeviceChangeListener(this);
129 125
130 // We have successfully opened the stream. Set the initial volume. 126 // We have successfully opened the stream. Set the initial volume.
131 stream_->SetVolume(volume_); 127 stream_->SetVolume(volume_);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 case kStarting: 245 case kStarting:
250 case kPlaying: 246 case kPlaying:
251 case kPaused: 247 case kPaused:
252 stream_->SetVolume(volume_); 248 stream_->SetVolume(volume_);
253 break; 249 break;
254 default: 250 default:
255 return; 251 return;
256 } 252 }
257 } 253 }
258 254
259 void AudioOutputController::DoReportError(int code) { 255 void AudioOutputController::DoReportError() {
260 DCHECK(message_loop_->BelongsToCurrentThread()); 256 DCHECK(message_loop_->BelongsToCurrentThread());
261 if (state_ != kClosed) 257 if (state_ != kClosed)
262 handler_->OnError(this, code); 258 handler_->OnError(this);
263 } 259 }
264 260
265 int AudioOutputController::OnMoreData(AudioBus* dest, 261 int AudioOutputController::OnMoreData(AudioBus* dest,
266 AudioBuffersState buffers_state) { 262 AudioBuffersState buffers_state) {
267 return OnMoreIOData(NULL, dest, buffers_state); 263 return OnMoreIOData(NULL, dest, buffers_state);
268 } 264 }
269 265
270 int AudioOutputController::OnMoreIOData(AudioBus* source, 266 int AudioOutputController::OnMoreIOData(AudioBus* source,
271 AudioBus* dest, 267 AudioBus* dest,
272 AudioBuffersState buffers_state) { 268 AudioBuffersState buffers_state) {
(...skipping 24 matching lines...) Expand all
297 // Wait for up to 683ms for DataReady(). 683ms was chosen because it's larger 293 // Wait for up to 683ms for DataReady(). 683ms was chosen because it's larger
298 // than the playback time of the WaveOut buffer size using the minimum 294 // than the playback time of the WaveOut buffer size using the minimum
299 // supported sample rate: 2048 / 3000 = ~683ms. 295 // supported sample rate: 2048 / 3000 = ~683ms.
300 const base::TimeDelta kMaxWait = base::TimeDelta::FromMilliseconds(683); 296 const base::TimeDelta kMaxWait = base::TimeDelta::FromMilliseconds(683);
301 while (!sync_reader_->DataReady() && 297 while (!sync_reader_->DataReady() &&
302 ((base::Time::Now() - start) < kMaxWait)) { 298 ((base::Time::Now() - start) < kMaxWait)) {
303 base::PlatformThread::YieldCurrentThread(); 299 base::PlatformThread::YieldCurrentThread();
304 } 300 }
305 } 301 }
306 302
307 void AudioOutputController::OnError(AudioOutputStream* stream, int code) { 303 void AudioOutputController::OnError(AudioOutputStream* stream) {
308 // Handle error on the audio controller thread. 304 // Handle error on the audio controller thread.
309 message_loop_->PostTask(FROM_HERE, base::Bind( 305 message_loop_->PostTask(FROM_HERE, base::Bind(
310 &AudioOutputController::DoReportError, this, code)); 306 &AudioOutputController::DoReportError, this));
311 } 307 }
312 308
313 void AudioOutputController::DoStopCloseAndClearStream() { 309 void AudioOutputController::DoStopCloseAndClearStream() {
314 DCHECK(message_loop_->BelongsToCurrentThread()); 310 DCHECK(message_loop_->BelongsToCurrentThread());
315 311
316 // Allow calling unconditionally and bail if we don't have a stream_ to close. 312 // Allow calling unconditionally and bail if we don't have a stream_ to close.
317 if (stream_) { 313 if (stream_) {
318 // De-register from state change callbacks if stream_ was created via 314 // De-register from state change callbacks if stream_ was created via
319 // AudioManager. 315 // AudioManager.
320 if (stream_ != diverting_to_stream_) 316 if (stream_ != diverting_to_stream_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); 401 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_));
406 base::AtomicRefCountInc(&num_allowed_io_); 402 base::AtomicRefCountInc(&num_allowed_io_);
407 } 403 }
408 404
409 void AudioOutputController::DisallowEntryToOnMoreIOData() { 405 void AudioOutputController::DisallowEntryToOnMoreIOData() {
410 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); 406 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_);
411 DCHECK(is_zero); 407 DCHECK(is_zero);
412 } 408 }
413 409
414 } // namespace media 410 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/audio/audio_output_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698