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

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

Issue 2004283002: AudioConverter: Express delay in frames rather than msec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed files & removed rounding Created 4 years, 6 months 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/audio/virtual_audio_output_stream.h ('k') | media/base/audio_buffer_converter.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 #include "media/audio/virtual_audio_output_stream.h" 5 #include "media/audio/virtual_audio_output_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/virtual_audio_input_stream.h" 10 #include "media/audio/virtual_audio_input_stream.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 DCHECK(thread_checker_.CalledOnValidThread()); 67 DCHECK(thread_checker_.CalledOnValidThread());
68 volume_ = volume; 68 volume_ = volume;
69 } 69 }
70 70
71 void VirtualAudioOutputStream::GetVolume(double* volume) { 71 void VirtualAudioOutputStream::GetVolume(double* volume) {
72 DCHECK(thread_checker_.CalledOnValidThread()); 72 DCHECK(thread_checker_.CalledOnValidThread());
73 *volume = volume_; 73 *volume = volume_;
74 } 74 }
75 75
76 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, 76 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus,
77 base::TimeDelta buffer_delay) { 77 uint32_t frames_delayed) {
78 // Note: This method may be invoked on any one thread, depending on the 78 // Note: This method may be invoked on any one thread, depending on the
79 // platform. 79 // platform.
80 DCHECK(callback_); 80 DCHECK(callback_);
81 81
82 DCHECK_GE(buffer_delay, base::TimeDelta()); 82 const uint32_t upstream_delay_in_bytes =
83 const int64_t upstream_delay_in_bytes = params_.GetBytesPerSecond() * 83 params_.GetBytesPerFrame() * frames_delayed;
84 buffer_delay / 84 const int frames =
85 base::TimeDelta::FromSeconds(1); 85 callback_->OnMoreData(audio_bus, upstream_delay_in_bytes, 0);
86 const int frames = callback_->OnMoreData(
87 audio_bus, static_cast<uint32_t>(upstream_delay_in_bytes), 0);
88 if (frames < audio_bus->frames()) 86 if (frames < audio_bus->frames())
89 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); 87 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames);
90 88
91 return frames > 0 ? volume_ : 0; 89 return frames > 0 ? volume_ : 0;
92 } 90 }
93 91
94 } // namespace media 92 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/virtual_audio_output_stream.h ('k') | media/base/audio_buffer_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698