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

Unified Diff: media/audio/pulse/pulse_input.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/pulse/pulse_input.cc
diff --git a/media/audio/pulse/pulse_input.cc b/media/audio/pulse/pulse_input.cc
index b27fb65694c61669d67675bc1debcbe15f035550..5a5750a949e8e3eca8e166ade91f3796e5686bf9 100644
--- a/media/audio/pulse/pulse_input.cc
+++ b/media/audio/pulse/pulse_input.cc
@@ -270,8 +270,7 @@ void PulseAudioInputStream::StreamNotifyCallback(pa_stream* s,
}
void PulseAudioInputStream::ReadData() {
- uint32_t hardware_delay = pulse::GetHardwareLatencyInBytes(
- handle_, params_.sample_rate(), params_.GetBytesPerFrame());
+ base::TimeDelta hardware_delay = pulse::GetHardwareLatency(handle_);
// Update the AGC volume level once every second. Note that,
// |volume| is also updated each time SetVolume() is called
@@ -309,8 +308,11 @@ void PulseAudioInputStream::ReadData() {
const AudioBus* audio_bus = fifo_.Consume();
// Compensate the audio delay caused by the FIFO.
- hardware_delay += fifo_.GetAvailableFrames() * params_.GetBytesPerFrame();
- callback_->OnData(this, audio_bus, hardware_delay, normalized_volume);
+ hardware_delay += base::TimeDelta::FromSecondsD(
+ fifo_.GetAvailableFrames() /
+ static_cast<double>(params_.sample_rate()));
o1ka 2017/02/10 13:28:50 I'm not sure if this is a good enough approximatio
DaleCurtis 2017/02/11 01:43:13 It's a good question, the answer is they don't. I'
+ callback_->OnData(this, audio_bus, hardware_delay, base::TimeTicks::Now(),
+ normalized_volume);
// Sleep 5ms to wait until render consumes the data in order to avoid
// back to back OnData() method.

Powered by Google App Engine
This is Rietveld 408576698