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

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

Issue 231623005: Remove obsolete atomic debugging checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/base/sinc_resampler.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 "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 23 matching lines...) Expand all
34 const std::string& output_device_id, 34 const std::string& output_device_id,
35 SyncReader* sync_reader) 35 SyncReader* sync_reader)
36 : audio_manager_(audio_manager), 36 : audio_manager_(audio_manager),
37 params_(params), 37 params_(params),
38 handler_(handler), 38 handler_(handler),
39 output_device_id_(output_device_id), 39 output_device_id_(output_device_id),
40 stream_(NULL), 40 stream_(NULL),
41 diverting_to_stream_(NULL), 41 diverting_to_stream_(NULL),
42 volume_(1.0), 42 volume_(1.0),
43 state_(kEmpty), 43 state_(kEmpty),
44 not_currently_in_on_more_io_data_(1),
45 sync_reader_(sync_reader), 44 sync_reader_(sync_reader),
46 message_loop_(audio_manager->GetTaskRunner()), 45 message_loop_(audio_manager->GetTaskRunner()),
47 #if defined(AUDIO_POWER_MONITORING) 46 #if defined(AUDIO_POWER_MONITORING)
48 power_monitor_( 47 power_monitor_(
49 params.sample_rate(), 48 params.sample_rate(),
50 TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMillis)), 49 TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMillis)),
51 #endif 50 #endif
52 on_more_io_data_called_(0) { 51 on_more_io_data_called_(0) {
53 DCHECK(audio_manager); 52 DCHECK(audio_manager);
54 DCHECK(handler_); 53 DCHECK(handler_);
55 DCHECK(sync_reader_); 54 DCHECK(sync_reader_);
56 DCHECK(message_loop_.get()); 55 DCHECK(message_loop_.get());
57 } 56 }
58 57
59 AudioOutputController::~AudioOutputController() { 58 AudioOutputController::~AudioOutputController() {
60 DCHECK_EQ(kClosed, state_); 59 DCHECK_EQ(kClosed, state_);
61 // TODO(dalecurtis): Remove debugging for http://crbug.com/349651
62 CHECK(!base::AtomicRefCountDec(&not_currently_in_on_more_io_data_));
63 } 60 }
64 61
65 // static 62 // static
66 scoped_refptr<AudioOutputController> AudioOutputController::Create( 63 scoped_refptr<AudioOutputController> AudioOutputController::Create(
67 AudioManager* audio_manager, 64 AudioManager* audio_manager,
68 EventHandler* event_handler, 65 EventHandler* event_handler,
69 const AudioParameters& params, 66 const AudioParameters& params,
70 const std::string& output_device_id, 67 const std::string& output_device_id,
71 SyncReader* sync_reader) { 68 SyncReader* sync_reader) {
72 DCHECK(audio_manager); 69 DCHECK(audio_manager);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 294 }
298 295
299 int AudioOutputController::OnMoreData(AudioBus* dest, 296 int AudioOutputController::OnMoreData(AudioBus* dest,
300 AudioBuffersState buffers_state) { 297 AudioBuffersState buffers_state) {
301 return OnMoreIOData(NULL, dest, buffers_state); 298 return OnMoreIOData(NULL, dest, buffers_state);
302 } 299 }
303 300
304 int AudioOutputController::OnMoreIOData(AudioBus* source, 301 int AudioOutputController::OnMoreIOData(AudioBus* source,
305 AudioBus* dest, 302 AudioBus* dest,
306 AudioBuffersState buffers_state) { 303 AudioBuffersState buffers_state) {
307 CHECK(!base::AtomicRefCountDec(&not_currently_in_on_more_io_data_));
308 TRACE_EVENT0("audio", "AudioOutputController::OnMoreIOData"); 304 TRACE_EVENT0("audio", "AudioOutputController::OnMoreIOData");
309 305
310 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck() 306 // Indicate that we haven't wedged (at least not indefinitely, WedgeCheck()
311 // may have already fired if OnMoreIOData() took an abnormal amount of time). 307 // may have already fired if OnMoreIOData() took an abnormal amount of time).
312 // Since this thread is the only writer of |on_more_io_data_called_| once the 308 // Since this thread is the only writer of |on_more_io_data_called_| once the
313 // thread starts, its safe to compare and then increment. 309 // thread starts, its safe to compare and then increment.
314 if (base::AtomicRefCountIsZero(&on_more_io_data_called_)) 310 if (base::AtomicRefCountIsZero(&on_more_io_data_called_))
315 base::AtomicRefCountInc(&on_more_io_data_called_); 311 base::AtomicRefCountInc(&on_more_io_data_called_);
316 312
317 sync_reader_->Read(source, dest); 313 sync_reader_->Read(source, dest);
318 314
319 const int frames = dest->frames(); 315 const int frames = dest->frames();
320 sync_reader_->UpdatePendingBytes( 316 sync_reader_->UpdatePendingBytes(
321 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame()); 317 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
322 318
323 #if defined(AUDIO_POWER_MONITORING) 319 #if defined(AUDIO_POWER_MONITORING)
324 power_monitor_.Scan(*dest, frames); 320 power_monitor_.Scan(*dest, frames);
325 #endif 321 #endif
326 322
327 base::AtomicRefCountInc(&not_currently_in_on_more_io_data_);
328 return frames; 323 return frames;
329 } 324 }
330 325
331 void AudioOutputController::OnError(AudioOutputStream* stream) { 326 void AudioOutputController::OnError(AudioOutputStream* stream) {
332 // Handle error on the audio controller thread. 327 // Handle error on the audio controller thread.
333 message_loop_->PostTask(FROM_HERE, base::Bind( 328 message_loop_->PostTask(FROM_HERE, base::Bind(
334 &AudioOutputController::DoReportError, this)); 329 &AudioOutputController::DoReportError, this));
335 } 330 }
336 331
337 void AudioOutputController::DoStopCloseAndClearStream() { 332 void AudioOutputController::DoStopCloseAndClearStream() {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 UMA_HISTOGRAM_BOOLEAN( 441 UMA_HISTOGRAM_BOOLEAN(
447 "Media.AudioOutputControllerPlaybackStartupSuccess", playback_success); 442 "Media.AudioOutputControllerPlaybackStartupSuccess", playback_success);
448 443
449 // Let the AudioManager try and fix it. 444 // Let the AudioManager try and fix it.
450 if (!playback_success) 445 if (!playback_success)
451 audio_manager_->FixWedgedAudio(); 446 audio_manager_->FixWedgedAudio();
452 } 447 }
453 } 448 }
454 449
455 } // namespace media 450 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | media/base/sinc_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698