| 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/base/audio_renderer_mixer.h" | 5 #include "media/base/audio_renderer_mixer.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // An error callback should always exist when called. | 112 // An error callback should always exist when called. |
| 113 NOTREACHED(); | 113 NOTREACHED(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 OutputDeviceInfo AudioRendererMixer::GetOutputDeviceInfo() { | 116 OutputDeviceInfo AudioRendererMixer::GetOutputDeviceInfo() { |
| 117 DVLOG(1) << __FUNCTION__; | 117 DVLOG(1) << __FUNCTION__; |
| 118 return audio_sink_->GetOutputDeviceInfo(); | 118 return audio_sink_->GetOutputDeviceInfo(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool AudioRendererMixer::CurrentThreadIsRenderingThread() { |
| 122 return audio_sink_->CurrentThreadIsRenderingThread(); |
| 123 } |
| 124 |
| 121 int AudioRendererMixer::Render(AudioBus* audio_bus, | 125 int AudioRendererMixer::Render(AudioBus* audio_bus, |
| 122 uint32_t frames_delayed, | 126 uint32_t frames_delayed, |
| 123 uint32_t frames_skipped) { | 127 uint32_t frames_skipped) { |
| 124 base::AutoLock auto_lock(lock_); | 128 base::AutoLock auto_lock(lock_); |
| 125 | 129 |
| 126 // If there are no mixer inputs and we haven't seen one for a while, pause the | 130 // If there are no mixer inputs and we haven't seen one for a while, pause the |
| 127 // sink to avoid wasting resources when media elements are present but remain | 131 // sink to avoid wasting resources when media elements are present but remain |
| 128 // in the pause state. | 132 // in the pause state. |
| 129 const base::TimeTicks now = base::TimeTicks::Now(); | 133 const base::TimeTicks now = base::TimeTicks::Now(); |
| 130 if (!master_converter_.empty()) { | 134 if (!master_converter_.empty()) { |
| 131 last_play_time_ = now; | 135 last_play_time_ = now; |
| 132 } else if (now - last_play_time_ >= pause_delay_ && playing_) { | 136 } else if (now - last_play_time_ >= pause_delay_ && playing_) { |
| 133 audio_sink_->Pause(); | 137 audio_sink_->Pause(); |
| 134 playing_ = false; | 138 playing_ = false; |
| 135 } | 139 } |
| 136 | 140 |
| 137 master_converter_.ConvertWithDelay(frames_delayed, audio_bus); | 141 master_converter_.ConvertWithDelay(frames_delayed, audio_bus); |
| 138 return audio_bus->frames(); | 142 return audio_bus->frames(); |
| 139 } | 143 } |
| 140 | 144 |
| 141 void AudioRendererMixer::OnRenderError() { | 145 void AudioRendererMixer::OnRenderError() { |
| 142 // Call each mixer input and signal an error. | 146 // Call each mixer input and signal an error. |
| 143 base::AutoLock auto_lock(lock_); | 147 base::AutoLock auto_lock(lock_); |
| 144 for (const auto& cb : error_callbacks_) | 148 for (const auto& cb : error_callbacks_) |
| 145 cb.Run(); | 149 cb.Run(); |
| 146 } | 150 } |
| 147 | 151 |
| 148 } // namespace media | 152 } // namespace media |
| OLD | NEW |