| OLD | NEW |
| 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_device.h" | 5 #include "media/audio/audio_output_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 void AudioOutputDevice::Initialize(const AudioParameters& params, | 91 void AudioOutputDevice::Initialize(const AudioParameters& params, |
| 92 RenderCallback* callback) { | 92 RenderCallback* callback) { |
| 93 DCHECK(!callback_) << "Calling Initialize() twice?"; | 93 DCHECK(!callback_) << "Calling Initialize() twice?"; |
| 94 DCHECK(params.IsValid()); | 94 DCHECK(params.IsValid()); |
| 95 audio_parameters_ = params; | 95 audio_parameters_ = params; |
| 96 callback_ = callback; | 96 callback_ = callback; |
| 97 } | 97 } |
| 98 | 98 |
| 99 AudioOutputDevice::~AudioOutputDevice() {} | 99 AudioOutputDevice::~AudioOutputDevice() { |
| 100 #if DCHECK_IS_ON() |
| 101 // Make sure we've stopped the stream properly before destructing |this|. |
| 102 DCHECK(audio_thread_lock_.Try()); |
| 103 DCHECK_LE(state_, IDLE); |
| 104 DCHECK(!audio_thread_); |
| 105 DCHECK(!audio_callback_); |
| 106 DCHECK(!stopping_hack_); |
| 107 audio_thread_lock_.Release(); |
| 108 #endif // DCHECK_IS_ON() |
| 109 } |
| 100 | 110 |
| 101 void AudioOutputDevice::RequestDeviceAuthorization() { | 111 void AudioOutputDevice::RequestDeviceAuthorization() { |
| 102 task_runner()->PostTask( | 112 task_runner()->PostTask( |
| 103 FROM_HERE, | 113 FROM_HERE, |
| 104 base::Bind(&AudioOutputDevice::RequestDeviceAuthorizationOnIOThread, | 114 base::Bind(&AudioOutputDevice::RequestDeviceAuthorizationOnIOThread, |
| 105 this)); | 115 this)); |
| 106 } | 116 } |
| 107 | 117 |
| 108 void AudioOutputDevice::Start() { | 118 void AudioOutputDevice::Start() { |
| 109 DCHECK(callback_) << "Initialize hasn't been called"; | 119 DCHECK(callback_) << "Initialize hasn't been called"; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 render_callback_->Render(delay, delay_timestamp, frames_skipped, | 497 render_callback_->Render(delay, delay_timestamp, frames_skipped, |
| 488 output_bus_.get()); | 498 output_bus_.get()); |
| 489 } | 499 } |
| 490 | 500 |
| 491 bool AudioOutputDevice::AudioThreadCallback:: | 501 bool AudioOutputDevice::AudioThreadCallback:: |
| 492 CurrentThreadIsAudioDeviceThread() { | 502 CurrentThreadIsAudioDeviceThread() { |
| 493 return thread_checker_.CalledOnValidThread(); | 503 return thread_checker_.CalledOnValidThread(); |
| 494 } | 504 } |
| 495 | 505 |
| 496 } // namespace media | 506 } // namespace media |
| OLD | NEW |