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

Side by Side Diff: media/audio/virtual_audio_input_stream.cc

Issue 756733003: Fix latency plumbing in media::VirtualAudio[Input|Output]Stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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/audio/virtual_audio_input_stream.h" 5 #include "media/audio/virtual_audio_input_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 20 matching lines...) Expand all
31 audio_converter_.AddInput(input); 31 audio_converter_.AddInput(input);
32 } 32 }
33 33
34 void RemoveInput(AudioConverter::InputCallback* input) { 34 void RemoveInput(AudioConverter::InputCallback* input) {
35 audio_converter_.RemoveInput(input); 35 audio_converter_.RemoveInput(input);
36 } 36 }
37 37
38 private: 38 private:
39 double ProvideInput(AudioBus* audio_bus, 39 double ProvideInput(AudioBus* audio_bus,
40 base::TimeDelta buffer_delay) override { 40 base::TimeDelta buffer_delay) override {
41 audio_converter_.Convert(audio_bus); 41 audio_converter_.ConvertWithDelay(buffer_delay, audio_bus);
42 return 1.0; 42 return 1.0;
43 } 43 }
44 44
45 AudioConverter audio_converter_; 45 AudioConverter audio_converter_;
46 46
47 DISALLOW_COPY_AND_ASSIGN(LoopbackAudioConverter); 47 DISALLOW_COPY_AND_ASSIGN(LoopbackAudioConverter);
48 }; 48 };
49 49
50 VirtualAudioInputStream::VirtualAudioInputStream( 50 VirtualAudioInputStream::VirtualAudioInputStream(
51 const AudioParameters& params, 51 const AudioParameters& params,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 --num_attached_output_streams_; 131 --num_attached_output_streams_;
132 DCHECK_LE(0, num_attached_output_streams_); 132 DCHECK_LE(0, num_attached_output_streams_);
133 } 133 }
134 134
135 void VirtualAudioInputStream::PumpAudio(AudioBus* audio_bus) { 135 void VirtualAudioInputStream::PumpAudio(AudioBus* audio_bus) {
136 DCHECK(worker_task_runner_->BelongsToCurrentThread()); 136 DCHECK(worker_task_runner_->BelongsToCurrentThread());
137 137
138 { 138 {
139 base::AutoLock scoped_lock(converter_network_lock_); 139 base::AutoLock scoped_lock(converter_network_lock_);
140 mixer_.Convert(audio_bus); 140 // Because the audio is being looped-back, the delay until it will be played
141 // out is zero.
142 mixer_.ConvertWithDelay(base::TimeDelta(), audio_bus);
141 } 143 }
142 callback_->OnData(this, audio_bus, params_.GetBytesPerBuffer(), 1.0); 144 // Because the audio is being looped-back, the delay since since it was
145 // recorded is zero.
146 callback_->OnData(this, audio_bus, 0, 1.0);
143 } 147 }
144 148
145 void VirtualAudioInputStream::Close() { 149 void VirtualAudioInputStream::Close() {
146 DCHECK(thread_checker_.CalledOnValidThread()); 150 DCHECK(thread_checker_.CalledOnValidThread());
147 151
148 Stop(); // Make sure callback_ is no longer being used. 152 Stop(); // Make sure callback_ is no longer being used.
149 153
150 // If a non-null AfterCloseCallback was provided to the constructor, invoke it 154 // If a non-null AfterCloseCallback was provided to the constructor, invoke it
151 // here. The callback is moved to a stack-local first since |this| could be 155 // here. The callback is moved to a stack-local first since |this| could be
152 // destroyed during Run(). 156 // destroyed during Run().
(...skipping 18 matching lines...) Expand all
171 175
172 bool VirtualAudioInputStream::GetAutomaticGainControl() { 176 bool VirtualAudioInputStream::GetAutomaticGainControl() {
173 return false; 177 return false;
174 } 178 }
175 179
176 bool VirtualAudioInputStream::IsMuted() { 180 bool VirtualAudioInputStream::IsMuted() {
177 return false; 181 return false;
178 } 182 }
179 183
180 } // namespace media 184 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/virtual_audio_output_stream.cc » ('j') | media/audio/virtual_audio_output_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698