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

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

Issue 1942803002: Caching AudioOutputDevice instances in mixer manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, fix for sleep() compile error on win and a bit of cleanup around timeouts. Created 4 years, 7 months 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_input.h" 5 #include "media/base/audio_renderer_mixer_input.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "media/base/audio_renderer_mixer.h" 11 #include "media/base/audio_renderer_mixer.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 AudioRendererMixerInput::AudioRendererMixerInput( 15 AudioRendererMixerInput::AudioRendererMixerInput(
16 const GetMixerCB& get_mixer_cb, 16 const GetMixerCB& get_mixer_cb,
17 const RemoveMixerCB& remove_mixer_cb, 17 const RemoveMixerCB& remove_mixer_cb,
18 const GetDeviceInfoCB& get_device_info_cb,
18 const std::string& device_id, 19 const std::string& device_id,
19 const url::Origin& security_origin) 20 const url::Origin& security_origin)
20 : started_(false), 21 : started_(false),
21 playing_(false), 22 playing_(false),
22 volume_(1.0f), 23 volume_(1.0f),
23 get_mixer_cb_(get_mixer_cb), 24 get_mixer_cb_(get_mixer_cb),
24 remove_mixer_cb_(remove_mixer_cb), 25 remove_mixer_cb_(remove_mixer_cb),
26 get_device_info_cb_(get_device_info_cb),
25 device_id_(device_id), 27 device_id_(device_id),
26 security_origin_(security_origin), 28 security_origin_(security_origin),
27 mixer_(nullptr), 29 mixer_(nullptr),
28 callback_(nullptr), 30 callback_(nullptr),
29 error_cb_(base::Bind(&AudioRendererMixerInput::OnRenderError, 31 error_cb_(base::Bind(&AudioRendererMixerInput::OnRenderError,
30 base::Unretained(this))) {} 32 base::Unretained(this))) {}
31 33
32 AudioRendererMixerInput::~AudioRendererMixerInput() { 34 AudioRendererMixerInput::~AudioRendererMixerInput() {
33 DCHECK(!started_); 35 DCHECK(!started_);
34 DCHECK(!mixer_); 36 DCHECK(!mixer_);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 playing_ = false; 107 playing_ = false;
106 } 108 }
107 109
108 bool AudioRendererMixerInput::SetVolume(double volume) { 110 bool AudioRendererMixerInput::SetVolume(double volume) {
109 base::AutoLock auto_lock(volume_lock_); 111 base::AutoLock auto_lock(volume_lock_);
110 volume_ = volume; 112 volume_ = volume;
111 return true; 113 return true;
112 } 114 }
113 115
114 OutputDeviceInfo AudioRendererMixerInput::GetOutputDeviceInfo() { 116 OutputDeviceInfo AudioRendererMixerInput::GetOutputDeviceInfo() {
115 return mixer_ ? mixer_->GetOutputDeviceInfo() : OutputDeviceInfo(); 117 return mixer_ ? mixer_->GetOutputDeviceInfo()
118 : get_device_info_cb_.Run(device_id_, security_origin_);
116 } 119 }
117 120
118 void AudioRendererMixerInput::SwitchOutputDevice( 121 void AudioRendererMixerInput::SwitchOutputDevice(
119 const std::string& device_id, 122 const std::string& device_id,
120 const url::Origin& security_origin, 123 const url::Origin& security_origin,
121 const OutputDeviceStatusCB& callback) { 124 const OutputDeviceStatusCB& callback) {
122 if (!mixer_) { 125 if (!mixer_) {
123 if (pending_switch_callback_.is_null()) { 126 if (pending_switch_callback_.is_null()) {
124 pending_switch_callback_ = callback; 127 pending_switch_callback_ = callback;
125 pending_switch_device_id_ = device_id; 128 pending_switch_device_id_ = device_id;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 base::AutoLock auto_lock(volume_lock_); 185 base::AutoLock auto_lock(volume_lock_);
183 return frames_filled > 0 ? volume_ : 0; 186 return frames_filled > 0 ? volume_ : 0;
184 } 187 }
185 } 188 }
186 189
187 void AudioRendererMixerInput::OnRenderError() { 190 void AudioRendererMixerInput::OnRenderError() {
188 callback_->OnRenderError(); 191 callback_->OnRenderError();
189 } 192 }
190 193
191 } // namespace media 194 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698