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

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

Issue 2452183003: Revert of Make more media APIs aware of |delay| and |delay_timestamp| (Closed)
Patch Set: Created 4 years, 1 month 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"
11 #include "media/base/fake_audio_render_callback.h" 10 #include "media/base/fake_audio_render_callback.h"
12 11
13 namespace media { 12 namespace media {
14 13
15 FakeAudioRenderCallback::FakeAudioRenderCallback(double step) 14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step)
16 : half_fill_(false), 15 : half_fill_(false),
17 step_(step), 16 step_(step),
18 last_frames_delayed_(-1), 17 last_frames_delayed_(-1),
19 last_channel_count_(-1), 18 last_channel_count_(-1),
20 volume_(1) { 19 volume_(1) {
21 reset(); 20 reset();
22 } 21 }
23 22
24 FakeAudioRenderCallback::~FakeAudioRenderCallback() {} 23 FakeAudioRenderCallback::~FakeAudioRenderCallback() {}
25 24
26 int FakeAudioRenderCallback::Render(base::TimeDelta delay, 25 int FakeAudioRenderCallback::Render(AudioBus* audio_bus,
27 base::TimeTicks delay_timestamp, 26 uint32_t frames_delayed,
28 int prior_frames_skipped, 27 uint32_t frames_skipped) {
29 AudioBus* audio_bus) {
30 const int kSampleRate = 48000;
31 auto frames_delayed = AudioTimestampHelper::TimeToFrames(delay, kSampleRate);
32 return RenderInternal(audio_bus, frames_delayed, volume_); 28 return RenderInternal(audio_bus, frames_delayed, volume_);
33 } 29 }
34 30
35 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus, 31 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus,
36 uint32_t frames_delayed) { 32 uint32_t frames_delayed) {
37 // Volume should only be applied by the caller to ProvideInput, so don't bake 33 // Volume should only be applied by the caller to ProvideInput, so don't bake
38 // it into the rendered audio. 34 // it into the rendered audio.
39 RenderInternal(audio_bus, frames_delayed, 1.0); 35 RenderInternal(audio_bus, frames_delayed, 1.0);
40 return volume_; 36 return volume_;
41 } 37 }
(...skipping 17 matching lines...) Expand all
59 // Copy first channel into the rest of the channels. 55 // Copy first channel into the rest of the channels.
60 for (int i = 1; i < audio_bus->channels(); ++i) { 56 for (int i = 1; i < audio_bus->channels(); ++i) {
61 memcpy(audio_bus->channel(i), audio_bus->channel(0), 57 memcpy(audio_bus->channel(i), audio_bus->channel(0),
62 number_of_frames * sizeof(*audio_bus->channel(i))); 58 number_of_frames * sizeof(*audio_bus->channel(i)));
63 } 59 }
64 60
65 return number_of_frames; 61 return number_of_frames;
66 } 62 }
67 63
68 } // namespace media 64 } // 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