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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // sink to avoid wasting resources when media elements are present but remain | 128 // sink to avoid wasting resources when media elements are present but remain |
129 // in the pause state. | 129 // in the pause state. |
130 const base::TimeTicks now = base::TimeTicks::Now(); | 130 const base::TimeTicks now = base::TimeTicks::Now(); |
131 if (!master_converter_.empty()) { | 131 if (!master_converter_.empty()) { |
132 last_play_time_ = now; | 132 last_play_time_ = now; |
133 } else if (now - last_play_time_ >= pause_delay_ && playing_) { | 133 } else if (now - last_play_time_ >= pause_delay_ && playing_) { |
134 audio_sink_->Pause(); | 134 audio_sink_->Pause(); |
135 playing_ = false; | 135 playing_ = false; |
136 } | 136 } |
137 | 137 |
138 // TODO(chcunningham): Delete this conversion and change ConvertWith delay to | 138 master_converter_.ConvertWithDelay(frames_delayed, audio_bus); |
139 // expect a count of frames delayed instead of TimeDelta (less precise). | |
140 // See http://crbug.com/587522. | |
141 base::TimeDelta audio_delay = base::TimeDelta::FromMicroseconds( | |
142 std::round(frames_delayed * output_params_.GetMicrosecondsPerFrame())); | |
143 | |
144 master_converter_.ConvertWithDelay(audio_delay, audio_bus); | |
145 return audio_bus->frames(); | 139 return audio_bus->frames(); |
146 } | 140 } |
147 | 141 |
148 void AudioRendererMixer::OnRenderError() { | 142 void AudioRendererMixer::OnRenderError() { |
149 // Call each mixer input and signal an error. | 143 // Call each mixer input and signal an error. |
150 base::AutoLock auto_lock(lock_); | 144 base::AutoLock auto_lock(lock_); |
151 for (const auto& cb : error_callbacks_) | 145 for (const auto& cb : error_callbacks_) |
152 cb.Run(); | 146 cb.Run(); |
153 } | 147 } |
154 | 148 |
155 } // namespace media | 149 } // namespace media |
OLD | NEW |