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

Side by Side Diff: media/base/audio_renderer_mixer.cc

Issue 1538563002: 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 fix. git cl format. Rebase. 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/base/audio_renderer_mixer.h ('k') | media/base/audio_renderer_mixer_input.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 (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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 NOTREACHED(); 110 NOTREACHED();
111 } 111 }
112 112
113 OutputDevice* AudioRendererMixer::GetOutputDevice() { 113 OutputDevice* AudioRendererMixer::GetOutputDevice() {
114 DVLOG(1) << __FUNCTION__; 114 DVLOG(1) << __FUNCTION__;
115 base::AutoLock auto_lock(lock_); 115 base::AutoLock auto_lock(lock_);
116 return audio_sink_->GetOutputDevice(); 116 return audio_sink_->GetOutputDevice();
117 } 117 }
118 118
119 int AudioRendererMixer::Render(AudioBus* audio_bus, 119 int AudioRendererMixer::Render(AudioBus* audio_bus,
120 int audio_delay_milliseconds) { 120 uint32_t audio_delay_milliseconds,
121 uint32_t frames_skipped) {
121 base::AutoLock auto_lock(lock_); 122 base::AutoLock auto_lock(lock_);
122 123
123 // If there are no mixer inputs and we haven't seen one for a while, pause the 124 // If there are no mixer inputs and we haven't seen one for a while, pause the
124 // sink to avoid wasting resources when media elements are present but remain 125 // sink to avoid wasting resources when media elements are present but remain
125 // in the pause state. 126 // in the pause state.
126 const base::TimeTicks now = base::TimeTicks::Now(); 127 const base::TimeTicks now = base::TimeTicks::Now();
127 if (!master_converter_.empty()) { 128 if (!master_converter_.empty()) {
128 last_play_time_ = now; 129 last_play_time_ = now;
129 } else if (now - last_play_time_ >= pause_delay_ && playing_) { 130 } else if (now - last_play_time_ >= pause_delay_ && playing_) {
130 audio_sink_->Pause(); 131 audio_sink_->Pause();
131 playing_ = false; 132 playing_ = false;
132 } 133 }
133 134
134 master_converter_.ConvertWithDelay( 135 master_converter_.ConvertWithDelay(
135 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus); 136 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus);
136 return audio_bus->frames(); 137 return audio_bus->frames();
137 } 138 }
138 139
139 void AudioRendererMixer::OnRenderError() { 140 void AudioRendererMixer::OnRenderError() {
140 // Call each mixer input and signal an error. 141 // Call each mixer input and signal an error.
141 base::AutoLock auto_lock(lock_); 142 base::AutoLock auto_lock(lock_);
142 for (const auto& cb : error_callbacks_) 143 for (const auto& cb : error_callbacks_)
143 cb.Run(); 144 cb.Run();
144 } 145 }
145 146
146 } // namespace media 147 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer.h ('k') | media/base/audio_renderer_mixer_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698