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

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

Issue 1538463002: Revert of Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/fake_audio_render_callback.h" 10 #include "media/base/fake_audio_render_callback.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step) 14 FakeAudioRenderCallback::FakeAudioRenderCallback(double step)
15 : half_fill_(false), 15 : half_fill_(false),
16 step_(step), 16 step_(step),
17 last_audio_delay_milliseconds_(-1), 17 last_audio_delay_milliseconds_(-1),
18 last_channel_count_(-1), 18 last_channel_count_(-1),
19 volume_(1) { 19 volume_(1) {
20 reset(); 20 reset();
21 } 21 }
22 22
23 FakeAudioRenderCallback::~FakeAudioRenderCallback() {} 23 FakeAudioRenderCallback::~FakeAudioRenderCallback() {}
24 24
25 int FakeAudioRenderCallback::Render(AudioBus* audio_bus, 25 int FakeAudioRenderCallback::Render(AudioBus* audio_bus,
26 uint32_t audio_delay_milliseconds, 26 int audio_delay_milliseconds) {
27 uint32_t frames_skipped) {
28 last_audio_delay_milliseconds_ = audio_delay_milliseconds; 27 last_audio_delay_milliseconds_ = audio_delay_milliseconds;
29 last_channel_count_ = audio_bus->channels(); 28 last_channel_count_ = audio_bus->channels();
30 29
31 int number_of_frames = audio_bus->frames(); 30 int number_of_frames = audio_bus->frames();
32 if (half_fill_) 31 if (half_fill_)
33 number_of_frames /= 2; 32 number_of_frames /= 2;
34 33
35 // Fill first channel with a sine wave. 34 // Fill first channel with a sine wave.
36 for (int i = 0; i < number_of_frames; ++i) 35 for (int i = 0; i < number_of_frames; ++i)
37 audio_bus->channel(0)[i] = sin(2 * M_PI * (x_ + step_ * i)); 36 audio_bus->channel(0)[i] = sin(2 * M_PI * (x_ + step_ * i));
38 x_ += number_of_frames * step_; 37 x_ += number_of_frames * step_;
39 38
40 // Copy first channel into the rest of the channels. 39 // Copy first channel into the rest of the channels.
41 for (int i = 1; i < audio_bus->channels(); ++i) 40 for (int i = 1; i < audio_bus->channels(); ++i)
42 memcpy(audio_bus->channel(i), audio_bus->channel(0), 41 memcpy(audio_bus->channel(i), audio_bus->channel(0),
43 number_of_frames * sizeof(*audio_bus->channel(i))); 42 number_of_frames * sizeof(*audio_bus->channel(i)));
44 43
45 return number_of_frames; 44 return number_of_frames;
46 } 45 }
47 46
48 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus, 47 double FakeAudioRenderCallback::ProvideInput(AudioBus* audio_bus,
49 base::TimeDelta buffer_delay) { 48 base::TimeDelta buffer_delay) {
50 Render(audio_bus, buffer_delay.InMillisecondsF() + 0.5, 0); 49 Render(audio_bus, buffer_delay.InMillisecondsF() + 0.5);
51 return volume_; 50 return volume_;
52 } 51 }
53 52
54 } // namespace media 53 } // 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