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

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

Issue 1184473002: Add support for the audio-output-device switching IPC mechanism to the renderer lower layers (media… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 157
158 bool WebAudioSourceProviderImpl::SetVolume(double volume) { 158 bool WebAudioSourceProviderImpl::SetVolume(double volume) {
159 base::AutoLock auto_lock(sink_lock_); 159 base::AutoLock auto_lock(sink_lock_);
160 volume_ = volume; 160 volume_ = volume;
161 if (!client_) 161 if (!client_)
162 sink_->SetVolume(volume); 162 sink_->SetVolume(volume);
163 return true; 163 return true;
164 } 164 }
165 165
166 void WebAudioSourceProviderImpl::SwitchOutputDevice(
167 const std::string& device_id,
168 const GURL& security_origin,
169 scoped_ptr<SwitchOutputDeviceCallbackRunner> callback_runner) {
170 base::AutoLock auto_lock(sink_lock_);
171 if (!client_) {
172 sink_->SwitchOutputDevice(device_id, security_origin,
173 callback_runner.Pass());
174 } else {
175 callback_runner->Run(SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED);
176 }
177 }
178
166 void WebAudioSourceProviderImpl::Initialize( 179 void WebAudioSourceProviderImpl::Initialize(
167 const AudioParameters& params, 180 const AudioParameters& params,
168 RenderCallback* renderer) { 181 RenderCallback* renderer) {
169 base::AutoLock auto_lock(sink_lock_); 182 base::AutoLock auto_lock(sink_lock_);
170 CHECK(!renderer_); 183 CHECK(!renderer_);
171 renderer_ = renderer; 184 renderer_ = renderer;
172 185
173 DCHECK_EQ(state_, kStopped); 186 DCHECK_EQ(state_, kStopped);
174 sink_->Initialize(params, renderer); 187 sink_->Initialize(params, renderer);
175 188
176 // Keep track of the format in case the client hasn't yet been set. 189 // Keep track of the format in case the client hasn't yet been set.
177 channels_ = params.channels(); 190 channels_ = params.channels();
178 sample_rate_ = params.sample_rate(); 191 sample_rate_ = params.sample_rate();
179 192
180 if (!set_format_cb_.is_null()) 193 if (!set_format_cb_.is_null())
181 base::ResetAndReturn(&set_format_cb_).Run(); 194 base::ResetAndReturn(&set_format_cb_).Run();
182 } 195 }
183 196
184 void WebAudioSourceProviderImpl::OnSetFormat() { 197 void WebAudioSourceProviderImpl::OnSetFormat() {
185 base::AutoLock auto_lock(sink_lock_); 198 base::AutoLock auto_lock(sink_lock_);
186 if (!client_) 199 if (!client_)
187 return; 200 return;
188 201
189 // Inform Blink about the audio stream format. 202 // Inform Blink about the audio stream format.
190 client_->setFormat(channels_, sample_rate_); 203 client_->setFormat(channels_, sample_rate_);
191 } 204 }
192 205
193 } // namespace media 206 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698