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

Unified Diff: media/audio/audio_output_controller.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: Created 5 years, 1 month 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/audio_output_controller.cc
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index 8aa2b4f38acfdfa989986ab5f4b035c3f1627bc9..9ddafe4a78d46bb66156240ceb74599f0dbaedcb 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -36,7 +36,8 @@ AudioOutputController::AudioOutputController(
params.sample_rate(),
TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMillis)),
on_more_io_data_called_(0),
- ignore_errors_during_stop_close_(false) {
+ ignore_errors_during_stop_close_(false),
+ frames_skipped_(0) {
DCHECK(audio_manager);
DCHECK(handler_);
DCHECK(sync_reader_);
@@ -160,7 +161,7 @@ void AudioOutputController::DoPlay() {
return;
// Ask for first packet.
- sync_reader_->UpdatePendingBytes(0);
+ sync_reader_->UpdatePendingBytes(0, 0);
state_ = kPlaying;
@@ -213,7 +214,7 @@ void AudioOutputController::DoPause() {
// Let the renderer know we've stopped. Necessary to let PPAPI clients know
// audio has been shutdown. TODO(dalecurtis): This stinks. PPAPI should have
// a better way to know when it should exit PPB_Audio_Shared::Run().
- sync_reader_->UpdatePendingBytes(kuint32max);
+ sync_reader_->UpdatePendingBytes(kuint32max, 0);
handler_->OnPaused();
}
@@ -293,8 +294,11 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
sync_reader_->Read(dest);
const int frames = dest->frames();
- sync_reader_->UpdatePendingBytes(base::saturated_cast<uint32>(
- total_bytes_delay + frames * params_.GetBytesPerFrame()));
+ sync_reader_->UpdatePendingBytes(
+ base::saturated_cast<uint32>(total_bytes_delay +
tommi (sloooow) - chröme 2015/12/01 13:34:25 this saturated cast looks like a hack. :-/ Can we
Henrik Grunell 2015/12/03 17:01:07 Agree, I don't know why we would fear it overflowi
+ frames * params_.GetBytesPerFrame()),
+ frames_skipped_);
+ frames_skipped_ = 0;
if (will_monitor_audio_levels())
power_monitor_.Scan(*dest, frames);
@@ -302,6 +306,12 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
return frames;
}
+void AudioOutputController::OnSkippedData(uint32 frames_skipped) {
tommi (sloooow) - chröme 2015/12/01 13:34:25 thread check
Henrik Grunell 2015/12/03 17:01:06 Done.
+ // Store the number of skipped frames, will be passed to the provider in
+ // OnMoreData().
+ frames_skipped_ += frames_skipped;
+}
+
void AudioOutputController::OnError(AudioOutputStream* stream) {
{
base::AutoLock auto_lock(error_lock_);

Powered by Google App Engine
This is Rietveld 408576698