Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: media/base/audio_renderer_mixer_input.cc

Issue 2517503003: Reland: Make more media APIs aware of |delay| and |delay_timestamp| (Closed)
Patch Set: Comments from chcunningham@ and Dale Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_mixer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_input.h" 5 #include "media/base/audio_renderer_mixer_input.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "media/base/audio_renderer_mixer.h" 12 #include "media/base/audio_renderer_mixer.h"
13 #include "media/base/audio_renderer_mixer_pool.h" 13 #include "media/base/audio_renderer_mixer_pool.h"
14 #include "media/base/audio_timestamp_helper.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 AudioRendererMixerInput::AudioRendererMixerInput( 18 AudioRendererMixerInput::AudioRendererMixerInput(
18 AudioRendererMixerPool* mixer_pool, 19 AudioRendererMixerPool* mixer_pool,
19 int owner_id, 20 int owner_id,
20 const std::string& device_id, 21 const std::string& device_id,
21 const url::Origin& security_origin, 22 const url::Origin& security_origin,
22 AudioLatency::LatencyType latency) 23 AudioLatency::LatencyType latency)
23 : mixer_pool_(mixer_pool), 24 : mixer_pool_(mixer_pool),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 device_id_ = device_id; 162 device_id_ = device_id;
162 security_origin_ = security_origin; 163 security_origin_ = security_origin;
163 } 164 }
164 165
165 callback.Run(OUTPUT_DEVICE_STATUS_OK); 166 callback.Run(OUTPUT_DEVICE_STATUS_OK);
166 } 167 }
167 168
168 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, 169 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus,
169 uint32_t frames_delayed) { 170 uint32_t frames_delayed) {
170 TRACE_EVENT0("audio", "AudioRendererMixerInput::ProvideInput"); 171 TRACE_EVENT0("audio", "AudioRendererMixerInput::ProvideInput");
171 int frames_filled = callback_->Render(audio_bus, frames_delayed, 0); 172 const base::TimeDelta delay =
173 AudioTimestampHelper::FramesToTime(frames_delayed, params_.sample_rate());
174
175 int frames_filled =
176 callback_->Render(delay, base::TimeTicks::Now(), 0, audio_bus);
172 177
173 // AudioConverter expects unfilled frames to be zeroed. 178 // AudioConverter expects unfilled frames to be zeroed.
174 if (frames_filled < audio_bus->frames()) { 179 if (frames_filled < audio_bus->frames()) {
175 audio_bus->ZeroFramesPartial( 180 audio_bus->ZeroFramesPartial(
176 frames_filled, audio_bus->frames() - frames_filled); 181 frames_filled, audio_bus->frames() - frames_filled);
177 } 182 }
178 183
179 // We're reading |volume_| from the audio device thread and must avoid racing 184 // We're reading |volume_| from the audio device thread and must avoid racing
180 // with the main/media thread calls to SetVolume(). See thread safety comment 185 // with the main/media thread calls to SetVolume(). See thread safety comment
181 // in the header file. 186 // in the header file.
182 { 187 {
183 base::AutoLock auto_lock(volume_lock_); 188 base::AutoLock auto_lock(volume_lock_);
184 return frames_filled > 0 ? volume_ : 0; 189 return frames_filled > 0 ? volume_ : 0;
185 } 190 }
186 } 191 }
187 192
188 void AudioRendererMixerInput::OnRenderError() { 193 void AudioRendererMixerInput::OnRenderError() {
189 callback_->OnRenderError(); 194 callback_->OnRenderError();
190 } 195 }
191 196
192 } // namespace media 197 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_mixer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698