Index: media/audio/mac/audio_auhal_mac.cc |
diff --git a/media/audio/mac/audio_auhal_mac.cc b/media/audio/mac/audio_auhal_mac.cc |
index 39c4610495392cac6faa92da8ffb1e55c6b05656..46583b121b9233df420d0d4f86d7e851f6c12817 100644 |
--- a/media/audio/mac/audio_auhal_mac.cc |
+++ b/media/audio/mac/audio_auhal_mac.cc |
@@ -53,6 +53,7 @@ AUHALStream::AUHALStream(AudioManagerMac* manager, |
hardware_latency_frames_(0), |
stopped_(true), |
current_hardware_pending_bytes_(0), |
+ current_lost_frames_(0), |
last_sample_time_(0.0), |
last_number_of_frames_(0), |
total_lost_frames_(0), |
@@ -206,6 +207,15 @@ OSStatus AUHALStream::Render( |
UpdatePlayoutTimestamp(output_time_stamp); |
+ // Inform the source about any skipped (lost) frames. If we use a fifo this |
+ // will be out of sync with the fifo pulls (different buffer sizes), so we do |
+ // it here and not in ProvideInput(). |
+ if (lost_frames > 0) { |
+ base::AutoLock auto_lock(source_lock_); |
+ if (source_) |
+ source_->OnSkippedData(lost_frames); |
+ } |
+ |
// If the stream parameters change for any reason, we need to insert a FIFO |
// since the OnMoreData() pipeline can't handle frame size changes. |
if (number_of_frames != number_of_frames_) { |
@@ -248,11 +258,11 @@ void AUHALStream::ProvideInput(int frame_delay, AudioBus* dest) { |
} |
// Supply the input data and render the output data. |
- source_->OnMoreData( |
- dest, |
- current_hardware_pending_bytes_ + |
- frame_delay * params_.GetBytesPerFrame()); |
+ source_->OnMoreData(dest, current_hardware_pending_bytes_ + |
+ frame_delay * params_.GetBytesPerFrame(), |
+ current_lost_frames_); |
dest->Scale(volume_); |
+ current_lost_frames_ = 0; |
} |
// AUHAL callback. |
@@ -358,8 +368,9 @@ void AUHALStream::UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp) { |
DCHECK_GT(diff, last_number_of_frames_); |
// We're being asked to render samples post what we expected. Update the |
// glitch count etc and keep a record of the largest glitch. |
- auto lost_frames = diff - last_number_of_frames_; |
+ UInt32 lost_frames = diff - last_number_of_frames_; |
total_lost_frames_ += lost_frames; |
+ current_lost_frames_ += lost_frames; |
if (lost_frames > largest_glitch_frames_) |
largest_glitch_frames_ = lost_frames; |
++glitches_detected_; |