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

Unified Diff: media/audio/alsa/alsa_input.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop 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/alsa/alsa_input.cc
diff --git a/media/audio/alsa/alsa_input.cc b/media/audio/alsa/alsa_input.cc
index be414868ad91a7ac44eda71ef9b8f1577b471b0c..305d38950dd1936d42ba43c98fb2414ac961e102 100644
--- a/media/audio/alsa/alsa_input.cc
+++ b/media/audio/alsa/alsa_input.cc
@@ -200,8 +200,8 @@ void AlsaPcmInputStream::ReadAudio() {
}
int num_buffers = frames / params_.frames_per_buffer();
- uint32_t hardware_delay_bytes =
- static_cast<uint32_t>(GetCurrentDelay() * params_.GetBytesPerFrame());
+ base::TimeDelta hardware_delay = base::TimeDelta::FromSecondsD(
+ GetCurrentDelay() / static_cast<double>(params_.sample_rate()));
double normalized_volume = 0.0;
// Update the AGC volume level once every second. Note that, |volume| is
@@ -213,11 +213,10 @@ void AlsaPcmInputStream::ReadAudio() {
int frames_read = wrapper_->PcmReadi(device_handle_, audio_buffer_.get(),
params_.frames_per_buffer());
if (frames_read == params_.frames_per_buffer()) {
- audio_bus_->FromInterleaved(audio_buffer_.get(),
- audio_bus_->frames(),
+ audio_bus_->FromInterleaved(audio_buffer_.get(), audio_bus_->frames(),
params_.bits_per_sample() / 8);
- callback_->OnData(
- this, audio_bus_.get(), hardware_delay_bytes, normalized_volume);
+ callback_->OnData(this, audio_bus_.get(), hardware_delay,
+ base::TimeTicks::Now(), normalized_volume);
} else {
LOG(WARNING) << "PcmReadi returning less than expected frames: "
<< frames_read << " vs. " << params_.frames_per_buffer()

Powered by Google App Engine
This is Rietveld 408576698