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

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

Issue 487543002: Revert 290359 "Remove AudioBuffersState class." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 OnDeviceChange(); 283 OnDeviceChange();
284 } 284 }
285 285
286 void AudioOutputController::DoReportError() { 286 void AudioOutputController::DoReportError() {
287 DCHECK(message_loop_->BelongsToCurrentThread()); 287 DCHECK(message_loop_->BelongsToCurrentThread());
288 if (state_ != kClosed) 288 if (state_ != kClosed)
289 handler_->OnError(); 289 handler_->OnError();
290 } 290 }
291 291
292 int AudioOutputController::OnMoreData(AudioBus* dest, 292 int AudioOutputController::OnMoreData(AudioBus* dest,
293 int total_bytes_delay) { 293 AudioBuffersState buffers_state) {
294 TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); 294 TRACE_EVENT0("audio", "AudioOutputController::OnMoreData");
295 295
296 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck() 296 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck()
297 // may have already fired if OnMoreIOData() took an abnormal amount of time). 297 // may have already fired if OnMoreIOData() took an abnormal amount of time).
298 // Since this thread is the only writer of |on_more_io_data_called_| once the 298 // Since this thread is the only writer of |on_more_io_data_called_| once the
299 // thread starts, its safe to compare and then increment. 299 // thread starts, its safe to compare and then increment.
300 if (base::AtomicRefCountIsZero(&on_more_io_data_called_)) 300 if (base::AtomicRefCountIsZero(&on_more_io_data_called_))
301 base::AtomicRefCountInc(&on_more_io_data_called_); 301 base::AtomicRefCountInc(&on_more_io_data_called_);
302 302
303 sync_reader_->Read(dest); 303 sync_reader_->Read(dest);
304 304
305 const int frames = dest->frames(); 305 const int frames = dest->frames();
306 sync_reader_->UpdatePendingBytes( 306 sync_reader_->UpdatePendingBytes(
307 total_bytes_delay + frames * params_.GetBytesPerFrame()); 307 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
308 308
309 #if defined(AUDIO_POWER_MONITORING) 309 #if defined(AUDIO_POWER_MONITORING)
310 power_monitor_.Scan(*dest, frames); 310 power_monitor_.Scan(*dest, frames);
311 #endif 311 #endif
312 312
313 return frames; 313 return frames;
314 } 314 }
315 315
316 void AudioOutputController::OnError(AudioOutputStream* stream) { 316 void AudioOutputController::OnError(AudioOutputStream* stream) {
317 // Handle error on the audio controller thread. 317 // Handle error on the audio controller thread.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 DCHECK(message_loop_->BelongsToCurrentThread()); 424 DCHECK(message_loop_->BelongsToCurrentThread());
425 425
426 // If we should be playing and we haven't, that's a wedge. 426 // If we should be playing and we haven't, that's a wedge.
427 if (state_ == kPlaying) { 427 if (state_ == kPlaying) {
428 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess", 428 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess",
429 base::AtomicRefCountIsOne(&on_more_io_data_called_)); 429 base::AtomicRefCountIsOne(&on_more_io_data_called_));
430 } 430 }
431 } 431 }
432 432
433 } // namespace media 433 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/audio/audio_output_controller.h ('k') | trunk/src/media/audio/audio_output_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698