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

Side by Side Diff: media/blink/webaudiosourceprovider_impl.cc

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace RestartableAudioRendererSink with SwitchableAudioRendererSink in webmediaplayer_impl unit t… Created 4 years, 9 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 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/blink/webaudiosourceprovider_impl.h" 5 #include "media/blink/webaudiosourceprovider_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 AudioRendererSink::RenderCallback* const renderer_; 80 AudioRendererSink::RenderCallback* const renderer_;
81 const int channels_; 81 const int channels_;
82 const int sample_rate_; 82 const int sample_rate_;
83 83
84 WebAudioSourceProviderImpl::CopyAudioCB copy_audio_bus_callback_; 84 WebAudioSourceProviderImpl::CopyAudioCB copy_audio_bus_callback_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(TeeFilter); 86 DISALLOW_COPY_AND_ASSIGN(TeeFilter);
87 }; 87 };
88 88
89 WebAudioSourceProviderImpl::WebAudioSourceProviderImpl( 89 WebAudioSourceProviderImpl::WebAudioSourceProviderImpl(
90 const scoped_refptr<RestartableAudioRendererSink>& sink) 90 const scoped_refptr<SwitchableAudioRendererSink>& sink)
91 : volume_(1.0), 91 : volume_(1.0),
92 state_(kStopped), 92 state_(kStopped),
93 client_(nullptr), 93 client_(nullptr),
94 sink_(sink), 94 sink_(sink),
95 weak_factory_(this) {} 95 weak_factory_(this) {}
96 96
97 WebAudioSourceProviderImpl::~WebAudioSourceProviderImpl() { 97 WebAudioSourceProviderImpl::~WebAudioSourceProviderImpl() {
98 } 98 }
99 99
100 void WebAudioSourceProviderImpl::setClient( 100 void WebAudioSourceProviderImpl::setClient(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (!client_) 197 if (!client_)
198 sink_->SetVolume(volume); 198 sink_->SetVolume(volume);
199 return true; 199 return true;
200 } 200 }
201 201
202 OutputDevice* WebAudioSourceProviderImpl::GetOutputDevice() { 202 OutputDevice* WebAudioSourceProviderImpl::GetOutputDevice() {
203 base::AutoLock auto_lock(sink_lock_); 203 base::AutoLock auto_lock(sink_lock_);
204 return sink_->GetOutputDevice(); 204 return sink_->GetOutputDevice();
205 } 205 }
206 206
207 void WebAudioSourceProviderImpl::SwitchOutputDevice(
208 const std::string& device_id,
209 const url::Origin& security_origin,
210 const SwitchOutputDeviceCB& callback) {
211 base::AutoLock auto_lock(sink_lock_);
212 if (sink_)
Guido Urdaneta 2016/03/17 17:38:24 Shouldn't this one also have the "!client" check t
o1ka 2016/03/18 10:45:40 Agree. Done.
213 sink_->SwitchOutputDevice(device_id, security_origin, callback);
214 else
215 callback.Run(media::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
216 }
217
207 void WebAudioSourceProviderImpl::Initialize(const AudioParameters& params, 218 void WebAudioSourceProviderImpl::Initialize(const AudioParameters& params,
208 RenderCallback* renderer) { 219 RenderCallback* renderer) {
209 base::AutoLock auto_lock(sink_lock_); 220 base::AutoLock auto_lock(sink_lock_);
210 DCHECK_EQ(state_, kStopped); 221 DCHECK_EQ(state_, kStopped);
211 222
212 tee_filter_ = make_scoped_ptr( 223 tee_filter_ = make_scoped_ptr(
213 new TeeFilter(renderer, params.channels(), params.sample_rate())); 224 new TeeFilter(renderer, params.channels(), params.sample_rate()));
214 225
215 sink_->Initialize(params, tee_filter_.get()); 226 sink_->Initialize(params, tee_filter_.get());
216 227
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 269 }
259 270
260 return num_rendered_frames; 271 return num_rendered_frames;
261 } 272 }
262 273
263 void WebAudioSourceProviderImpl::TeeFilter::OnRenderError() { 274 void WebAudioSourceProviderImpl::TeeFilter::OnRenderError() {
264 renderer_->OnRenderError(); 275 renderer_->OnRenderError();
265 } 276 }
266 277
267 } // namespace media 278 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698