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

Side by Side Diff: media/audio/mac/audio_auhal_mac.cc

Issue 1487983002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in Windows unit test. Created 5 years 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 unified diff | Download patch
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/mac/audio_auhal_mac.h" 5 #include "media/audio/mac/audio_auhal_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 output_channels_(params_.channels()), 46 output_channels_(params_.channels()),
47 number_of_frames_(params_.frames_per_buffer()), 47 number_of_frames_(params_.frames_per_buffer()),
48 number_of_frames_requested_(0), 48 number_of_frames_requested_(0),
49 source_(NULL), 49 source_(NULL),
50 device_(device), 50 device_(device),
51 audio_unit_(0), 51 audio_unit_(0),
52 volume_(1), 52 volume_(1),
53 hardware_latency_frames_(0), 53 hardware_latency_frames_(0),
54 stopped_(true), 54 stopped_(true),
55 current_hardware_pending_bytes_(0), 55 current_hardware_pending_bytes_(0),
56 current_lost_frames_(0),
56 last_sample_time_(0.0), 57 last_sample_time_(0.0),
57 last_number_of_frames_(0), 58 last_number_of_frames_(0),
58 total_lost_frames_(0), 59 total_lost_frames_(0),
59 largest_glitch_frames_(0), 60 largest_glitch_frames_(0),
60 glitches_detected_(0) { 61 glitches_detected_(0) {
61 // We must have a manager. 62 // We must have a manager.
62 DCHECK(manager_); 63 DCHECK(manager_);
63 64
64 DVLOG(1) << "AUHALStream::AUHALStream()"; 65 DVLOG(1) << "AUHALStream::AUHALStream()";
65 DVLOG(1) << "Device: " << device; 66 DVLOG(1) << "Device: " << device;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 242 }
242 243
243 void AUHALStream::ProvideInput(int frame_delay, AudioBus* dest) { 244 void AUHALStream::ProvideInput(int frame_delay, AudioBus* dest) {
244 base::AutoLock auto_lock(source_lock_); 245 base::AutoLock auto_lock(source_lock_);
245 if (!source_) { 246 if (!source_) {
246 dest->Zero(); 247 dest->Zero();
247 return; 248 return;
248 } 249 }
249 250
250 // Supply the input data and render the output data. 251 // Supply the input data and render the output data.
251 source_->OnMoreData( 252 source_->OnMoreData(dest, current_hardware_pending_bytes_ +
252 dest, 253 frame_delay * params_.GetBytesPerFrame(),
253 current_hardware_pending_bytes_ + 254 current_lost_frames_);
254 frame_delay * params_.GetBytesPerFrame());
255 dest->Scale(volume_); 255 dest->Scale(volume_);
256 current_lost_frames_ = 0;
256 } 257 }
257 258
258 // AUHAL callback. 259 // AUHAL callback.
259 OSStatus AUHALStream::InputProc( 260 OSStatus AUHALStream::InputProc(
260 void* user_data, 261 void* user_data,
261 AudioUnitRenderActionFlags* flags, 262 AudioUnitRenderActionFlags* flags,
262 const AudioTimeStamp* output_time_stamp, 263 const AudioTimeStamp* output_time_stamp,
263 UInt32 bus_number, 264 UInt32 bus_number,
264 UInt32 number_of_frames, 265 UInt32 number_of_frames,
265 AudioBufferList* io_data) { 266 AudioBufferList* io_data) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (last_sample_time_) { 354 if (last_sample_time_) {
354 DCHECK_NE(0U, last_number_of_frames_); 355 DCHECK_NE(0U, last_number_of_frames_);
355 UInt32 diff = 356 UInt32 diff =
356 static_cast<UInt32>(timestamp->mSampleTime - last_sample_time_); 357 static_cast<UInt32>(timestamp->mSampleTime - last_sample_time_);
357 if (diff != last_number_of_frames_) { 358 if (diff != last_number_of_frames_) {
358 DCHECK_GT(diff, last_number_of_frames_); 359 DCHECK_GT(diff, last_number_of_frames_);
359 // We're being asked to render samples post what we expected. Update the 360 // We're being asked to render samples post what we expected. Update the
360 // glitch count etc and keep a record of the largest glitch. 361 // glitch count etc and keep a record of the largest glitch.
361 auto lost_frames = diff - last_number_of_frames_; 362 auto lost_frames = diff - last_number_of_frames_;
362 total_lost_frames_ += lost_frames; 363 total_lost_frames_ += lost_frames;
364 current_lost_frames_ += lost_frames;
363 if (lost_frames > largest_glitch_frames_) 365 if (lost_frames > largest_glitch_frames_)
364 largest_glitch_frames_ = lost_frames; 366 largest_glitch_frames_ = lost_frames;
365 ++glitches_detected_; 367 ++glitches_detected_;
366 } 368 }
367 } 369 }
368 370
369 // Store the last sample time for use next time we get called back. 371 // Store the last sample time for use next time we get called back.
370 last_sample_time_ = timestamp->mSampleTime; 372 last_sample_time_ = timestamp->mSampleTime;
371 } 373 }
372 374
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 OSStatus result = AudioUnitUninitialize(audio_unit_); 540 OSStatus result = AudioUnitUninitialize(audio_unit_);
539 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 541 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
540 << "AudioUnitUninitialize() failed."; 542 << "AudioUnitUninitialize() failed.";
541 result = AudioComponentInstanceDispose(audio_unit_); 543 result = AudioComponentInstanceDispose(audio_unit_);
542 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 544 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
543 << "AudioComponentInstanceDispose() failed."; 545 << "AudioComponentInstanceDispose() failed.";
544 audio_unit_ = 0; 546 audio_unit_ = 0;
545 } 547 }
546 548
547 } // namespace media 549 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698