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

Side by Side Diff: media/base/fake_audio_render_callback.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/fake_audio_render_callback.h ('k') | media/base/fake_audio_renderer_sink.h » ('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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "media/base/audio_timestamp_helper.h"
10 #include "media/base/fake_audio_render_callback.h" 11 #include "media/base/fake_audio_render_callback.h"
11 12
12 namespace media { 13 namespace media {
13 14
14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step) 15 FakeAudioRenderCallback::FakeAudioRenderCallback(double step)
15 : half_fill_(false), 16 : half_fill_(false),
16 step_(step), 17 step_(step),
17 last_frames_delayed_(-1), 18 last_frames_delayed_(-1),
18 last_channel_count_(-1), 19 last_channel_count_(-1),
19 volume_(1) { 20 volume_(1) {
20 reset(); 21 reset();
21 } 22 }
22 23
23 FakeAudioRenderCallback::~FakeAudioRenderCallback() {} 24 FakeAudioRenderCallback::~FakeAudioRenderCallback() {}
24 25
25 int FakeAudioRenderCallback::Render(AudioBus* audio_bus, 26 int FakeAudioRenderCallback::Render(base::TimeDelta delay,
26 uint32_t frames_delayed, 27 base::TimeTicks delay_timestamp,
27 uint32_t frames_skipped) { 28 int prior_frames_skipped,
29 AudioBus* audio_bus) {
30 const int kSampleRate = 48000;
31 auto frames_delayed = AudioTimestampHelper::TimeToFrames(delay, kSampleRate);
28 return RenderInternal(audio_bus, frames_delayed, volume_); 32 return RenderInternal(audio_bus, frames_delayed, volume_);
29 } 33 }
30 34
31 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus, 35 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus,
32 uint32_t frames_delayed) { 36 uint32_t frames_delayed) {
33 // Volume should only be applied by the caller to ProvideInput, so don't bake 37 // Volume should only be applied by the caller to ProvideInput, so don't bake
34 // it into the rendered audio. 38 // it into the rendered audio.
35 RenderInternal(audio_bus, frames_delayed, 1.0); 39 RenderInternal(audio_bus, frames_delayed, 1.0);
36 return volume_; 40 return volume_;
37 } 41 }
(...skipping 17 matching lines...) Expand all
55 // Copy first channel into the rest of the channels. 59 // Copy first channel into the rest of the channels.
56 for (int i = 1; i < audio_bus->channels(); ++i) { 60 for (int i = 1; i < audio_bus->channels(); ++i) {
57 memcpy(audio_bus->channel(i), audio_bus->channel(0), 61 memcpy(audio_bus->channel(i), audio_bus->channel(0),
58 number_of_frames * sizeof(*audio_bus->channel(i))); 62 number_of_frames * sizeof(*audio_bus->channel(i)));
59 } 63 }
60 64
61 return number_of_frames; 65 return number_of_frames;
62 } 66 }
63 67
64 } // namespace media 68 } // namespace media
OLDNEW
« no previous file with comments | « media/base/fake_audio_render_callback.h ('k') | media/base/fake_audio_renderer_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698