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

Side by Side Diff: media/base/audio_renderer_mixer.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: Code review fixes. Loads of files updated due to interface changes. 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/audio_renderer_mixer.h" 5 #include "media/base/audio_renderer_mixer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 NOTREACHED(); 71 NOTREACHED();
72 } 72 }
73 73
74 OutputDevice* AudioRendererMixer::GetOutputDevice() { 74 OutputDevice* AudioRendererMixer::GetOutputDevice() {
75 DVLOG(1) << __FUNCTION__; 75 DVLOG(1) << __FUNCTION__;
76 base::AutoLock auto_lock(lock_); 76 base::AutoLock auto_lock(lock_);
77 return audio_sink_->GetOutputDevice(); 77 return audio_sink_->GetOutputDevice();
78 } 78 }
79 79
80 int AudioRendererMixer::Render(AudioBus* audio_bus, 80 int AudioRendererMixer::Render(AudioBus* audio_bus,
81 int audio_delay_milliseconds) { 81 int audio_delay_milliseconds,
82 uint32_t frames_skipped) {
82 base::AutoLock auto_lock(lock_); 83 base::AutoLock auto_lock(lock_);
83 84
84 // If there are no mixer inputs and we haven't seen one for a while, pause the 85 // If there are no mixer inputs and we haven't seen one for a while, pause the
85 // sink to avoid wasting resources when media elements are present but remain 86 // sink to avoid wasting resources when media elements are present but remain
86 // in the pause state. 87 // in the pause state.
87 const base::TimeTicks now = base::TimeTicks::Now(); 88 const base::TimeTicks now = base::TimeTicks::Now();
88 if (!audio_converter_.empty()) { 89 if (!audio_converter_.empty()) {
89 last_play_time_ = now; 90 last_play_time_ = now;
90 } else if (now - last_play_time_ >= pause_delay_ && playing_) { 91 } else if (now - last_play_time_ >= pause_delay_ && playing_) {
91 audio_sink_->Pause(); 92 audio_sink_->Pause();
92 playing_ = false; 93 playing_ = false;
93 } 94 }
94 95
95 audio_converter_.ConvertWithDelay( 96 audio_converter_.ConvertWithDelay(
96 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus); 97 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus);
97 return audio_bus->frames(); 98 return audio_bus->frames();
98 } 99 }
99 100
100 void AudioRendererMixer::OnRenderError() { 101 void AudioRendererMixer::OnRenderError() {
101 // Call each mixer input and signal an error. 102 // Call each mixer input and signal an error.
102 base::AutoLock auto_lock(lock_); 103 base::AutoLock auto_lock(lock_);
103 for (const auto& cb : error_callbacks_) 104 for (const auto& cb : error_callbacks_)
104 cb.Run(); 105 cb.Run();
105 } 106 }
106 107
107 } // namespace media 108 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698