| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return audio_callback_->CurrentThreadIsAudioDeviceThread(); | 162 return audio_callback_->CurrentThreadIsAudioDeviceThread(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void AudioOutputDevice::RequestDeviceAuthorizationOnIOThread() { | 165 void AudioOutputDevice::RequestDeviceAuthorizationOnIOThread() { |
| 166 DCHECK(task_runner()->BelongsToCurrentThread()); | 166 DCHECK(task_runner()->BelongsToCurrentThread()); |
| 167 DCHECK_EQ(state_, IDLE); | 167 DCHECK_EQ(state_, IDLE); |
| 168 state_ = AUTHORIZING; | 168 state_ = AUTHORIZING; |
| 169 ipc_->RequestDeviceAuthorization(this, session_id_, device_id_, | 169 ipc_->RequestDeviceAuthorization(this, session_id_, device_id_, |
| 170 security_origin_); | 170 security_origin_); |
| 171 | 171 |
| 172 // Create the timer on the thread it's used on. It's guaranteed to be | 172 if (auth_timeout_ > 0) { |
| 173 // deleted on the same thread since users must call Stop() before deleting | 173 // Create the timer on the thread it's used on. It's guaranteed to be |
| 174 // AudioOutputDevice; see ShutDownOnIOThread(). | 174 // deleted on the same thread since users must call Stop() before deleting |
| 175 auth_timeout_action_.reset(new base::OneShotTimer()); | 175 // AudioOutputDevice; see ShutDownOnIOThread(). |
| 176 auth_timeout_action_->Start( | 176 auth_timeout_action_.reset(new base::OneShotTimer()); |
| 177 FROM_HERE, auth_timeout_, | 177 auth_timeout_action_->Start( |
| 178 base::Bind(&AudioOutputDevice::OnDeviceAuthorized, this, | 178 FROM_HERE, auth_timeout_, |
| 179 OUTPUT_DEVICE_STATUS_ERROR_TIMED_OUT, media::AudioParameters(), | 179 base::Bind(&AudioOutputDevice::OnDeviceAuthorized, this, |
| 180 std::string())); | 180 OUTPUT_DEVICE_STATUS_ERROR_TIMED_OUT, |
| 181 media::AudioParameters(), std::string())); |
| 182 } |
| 181 } | 183 } |
| 182 | 184 |
| 183 void AudioOutputDevice::CreateStreamOnIOThread(const AudioParameters& params) { | 185 void AudioOutputDevice::CreateStreamOnIOThread(const AudioParameters& params) { |
| 184 DCHECK(task_runner()->BelongsToCurrentThread()); | 186 DCHECK(task_runner()->BelongsToCurrentThread()); |
| 185 switch (state_) { | 187 switch (state_) { |
| 186 case IPC_CLOSED: | 188 case IPC_CLOSED: |
| 187 if (callback_) | 189 if (callback_) |
| 188 callback_->OnRenderError(); | 190 callback_->OnRenderError(); |
| 189 break; | 191 break; |
| 190 | 192 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 render_callback_->Render(output_bus_.get(), std::round(frames_delayed), | 492 render_callback_->Render(output_bus_.get(), std::round(frames_delayed), |
| 491 frames_skipped); | 493 frames_skipped); |
| 492 } | 494 } |
| 493 | 495 |
| 494 bool AudioOutputDevice::AudioThreadCallback:: | 496 bool AudioOutputDevice::AudioThreadCallback:: |
| 495 CurrentThreadIsAudioDeviceThread() { | 497 CurrentThreadIsAudioDeviceThread() { |
| 496 return thread_checker_.CalledOnValidThread(); | 498 return thread_checker_.CalledOnValidThread(); |
| 497 } | 499 } |
| 498 | 500 |
| 499 } // namespace media | 501 } // namespace media |
| OLD | NEW |