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

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

Issue 1492403002: Remove kuint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http security header file Created 5 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 | « media/audio/audio_device_thread.cc ('k') | net/disk_cache/blockfile/backend_impl.h » ('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 <stdint.h>
8
9 #include <limits>
10
7 #include "base/bind.h" 11 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
9 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
10 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
11 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
12 #include "base/time/time.h" 16 #include "base/time/time.h"
13 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
14 18
15 using base::TimeDelta; 19 using base::TimeDelta;
16 20
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 TRACE_EVENT0("audio", "AudioOutputController::DoPause"); 210 TRACE_EVENT0("audio", "AudioOutputController::DoPause");
207 211
208 StopStream(); 212 StopStream();
209 213
210 if (state_ != kPaused) 214 if (state_ != kPaused)
211 return; 215 return;
212 216
213 // Let the renderer know we've stopped. Necessary to let PPAPI clients know 217 // Let the renderer know we've stopped. Necessary to let PPAPI clients know
214 // audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have 218 // audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have
215 // a better way to know when it should exit PPB_Audio_Shared::Run(). 219 // a better way to know when it should exit PPB_Audio_Shared::Run().
216 sync_reader_->UpdatePendingBytes(kuint32max); 220 sync_reader_->UpdatePendingBytes(std::numeric_limits<uint32_t>::max());
217 221
218 handler_->OnPaused(); 222 handler_->OnPaused();
219 } 223 }
220 224
221 void AudioOutputController::DoClose() { 225 void AudioOutputController::DoClose() {
222 DCHECK(message_loop_->BelongsToCurrentThread()); 226 DCHECK(message_loop_->BelongsToCurrentThread());
223 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CloseTime"); 227 SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CloseTime");
224 TRACE_EVENT0("audio", "AudioOutputController::DoClose"); 228 TRACE_EVENT0("audio", "AudioOutputController::DoClose");
225 229
226 if (state_ != kClosed) { 230 if (state_ != kClosed) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 OnDeviceChange(); 277 OnDeviceChange();
274 } 278 }
275 279
276 void AudioOutputController::DoReportError() { 280 void AudioOutputController::DoReportError() {
277 DCHECK(message_loop_->BelongsToCurrentThread()); 281 DCHECK(message_loop_->BelongsToCurrentThread());
278 if (state_ != kClosed) 282 if (state_ != kClosed)
279 handler_->OnError(); 283 handler_->OnError();
280 } 284 }
281 285
282 int AudioOutputController::OnMoreData(AudioBus* dest, 286 int AudioOutputController::OnMoreData(AudioBus* dest,
283 uint32 total_bytes_delay) { 287 uint32_t total_bytes_delay) {
284 TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); 288 TRACE_EVENT0("audio", "AudioOutputController::OnMoreData");
285 289
286 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck() 290 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck()
287 // may have already fired if OnMoreData() took an abnormal amount of time). 291 // may have already fired if OnMoreData() took an abnormal amount of time).
288 // Since this thread is the only writer of |on_more_io_data_called_| once the 292 // Since this thread is the only writer of |on_more_io_data_called_| once the
289 // thread starts, its safe to compare and then increment. 293 // thread starts, its safe to compare and then increment.
290 if (base::AtomicRefCountIsZero(&on_more_io_data_called_)) 294 if (base::AtomicRefCountIsZero(&on_more_io_data_called_))
291 base::AtomicRefCountInc(&on_more_io_data_called_); 295 base::AtomicRefCountInc(&on_more_io_data_called_);
292 296
293 sync_reader_->Read(dest); 297 sync_reader_->Read(dest);
294 298
295 const int frames = dest->frames(); 299 const int frames = dest->frames();
296 sync_reader_->UpdatePendingBytes(base::saturated_cast<uint32>( 300 sync_reader_->UpdatePendingBytes(base::saturated_cast<uint32_t>(
297 total_bytes_delay + frames * params_.GetBytesPerFrame())); 301 total_bytes_delay + frames * params_.GetBytesPerFrame()));
298 302
299 if (will_monitor_audio_levels()) 303 if (will_monitor_audio_levels())
300 power_monitor_.Scan(*dest, frames); 304 power_monitor_.Scan(*dest, frames);
301 305
302 return frames; 306 return frames;
303 } 307 }
304 308
305 void AudioOutputController::OnError(AudioOutputStream* stream) { 309 void AudioOutputController::OnError(AudioOutputStream* stream) {
306 { 310 {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 DCHECK(message_loop_->BelongsToCurrentThread()); 427 DCHECK(message_loop_->BelongsToCurrentThread());
424 428
425 // If we should be playing and we haven't, that's a wedge. 429 // If we should be playing and we haven't, that's a wedge.
426 if (state_ == kPlaying) { 430 if (state_ == kPlaying) {
427 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess", 431 UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputControllerPlaybackStartupSuccess",
428 base::AtomicRefCountIsOne(&on_more_io_data_called_)); 432 base::AtomicRefCountIsOne(&on_more_io_data_called_));
429 } 433 }
430 } 434 }
431 435
432 } // namespace media 436 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.cc ('k') | net/disk_cache/blockfile/backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698