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