Index: media/audio/audio_output_device.cc |
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc |
index 3af32b7835f8f1f8a23c98b0a0a16f7fa4deb31c..7044e9ae770649c0477b9b37af56eca6fff01abb 100644 |
--- a/media/audio/audio_output_device.cc |
+++ b/media/audio/audio_output_device.cc |
@@ -6,6 +6,8 @@ |
#include <stddef.h> |
#include <stdint.h> |
+ |
+#include <cmath> |
#include <utility> |
#include "base/callback_helpers.h" |
@@ -413,8 +415,8 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { |
// Called whenever we receive notifications about pending data. |
void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
- // Convert the number of pending bytes in the render buffer into milliseconds. |
- uint32_t audio_delay_milliseconds = pending_data / bytes_per_ms_; |
+ // Convert the number of pending bytes in the render buffer into frames. |
+ double frames_delayed = static_cast<double>(pending_data) / bytes_per_frame_; |
callback_num_++; |
TRACE_EVENT1("audio", "AudioOutputDevice::FireRenderCallback", |
@@ -433,11 +435,15 @@ void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
uint32_t frames_skipped = buffer->params.frames_skipped; |
buffer->params.frames_skipped = 0; |
+ DVLOG(4) << __FUNCTION__ << " pending_data:" << pending_data |
+ << " frames_delayed(pre-round):" << frames_delayed |
+ << " frames_skipped:" << frames_skipped; |
+ |
// Update the audio-delay measurement, inform about the number of skipped |
// frames, and ask client to render audio. Since |output_bus_| is wrapping |
// the shared memory the Render() call is writing directly into the shared |
// memory. |
- render_callback_->Render(output_bus_.get(), audio_delay_milliseconds, |
+ render_callback_->Render(output_bus_.get(), std::round(frames_delayed), |
frames_skipped); |
} |