Chromium Code Reviews| 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. |