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

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: rebase Created 4 years, 8 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
« no previous file with comments | « media/blink/webaudiosourceprovider_impl.h ('k') | media/blink/webmediaplayer_impl.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 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 bool WebAudioSourceProviderImpl::SetVolume(double volume) { 194 bool WebAudioSourceProviderImpl::SetVolume(double volume) {
195 base::AutoLock auto_lock(sink_lock_); 195 base::AutoLock auto_lock(sink_lock_);
196 volume_ = volume; 196 volume_ = volume;
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 media::OutputDeviceInfo WebAudioSourceProviderImpl::GetOutputDeviceInfo() {
203 base::AutoLock auto_lock(sink_lock_); 203 base::AutoLock auto_lock(sink_lock_);
204 return sink_->GetOutputDevice(); 204 return client_ ? media::OutputDeviceInfo() : sink_->GetOutputDeviceInfo();
205 }
206
207 void WebAudioSourceProviderImpl::SwitchOutputDevice(
208 const std::string& device_id,
209 const url::Origin& security_origin,
210 const OutputDeviceStatusCB& callback) {
211 base::AutoLock auto_lock(sink_lock_);
212 if (client_)
213 callback.Run(media::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
214 else
215 sink_->SwitchOutputDevice(device_id, security_origin, callback);
205 } 216 }
206 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
(...skipping 43 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
« no previous file with comments | « media/blink/webaudiosourceprovider_impl.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698