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

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: Fix comments 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 const SwitchOutputDeviceCB& callback) {
170 base::AutoLock auto_lock(sink_lock_);
171 if (!client_) {
172 sink_->SwitchOutputDevice(device_id, security_origin, callback);
173 } else {
174 callback.Run(SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED);
175 }
176 }
177
166 void WebAudioSourceProviderImpl::Initialize( 178 void WebAudioSourceProviderImpl::Initialize(
167 const AudioParameters& params, 179 const AudioParameters& params,
168 RenderCallback* renderer) { 180 RenderCallback* renderer) {
169 base::AutoLock auto_lock(sink_lock_); 181 base::AutoLock auto_lock(sink_lock_);
170 CHECK(!renderer_); 182 CHECK(!renderer_);
171 renderer_ = renderer; 183 renderer_ = renderer;
172 184
173 DCHECK_EQ(state_, kStopped); 185 DCHECK_EQ(state_, kStopped);
174 sink_->Initialize(params, renderer); 186 sink_->Initialize(params, renderer);
175 187
176 // Keep track of the format in case the client hasn't yet been set. 188 // Keep track of the format in case the client hasn't yet been set.
177 channels_ = params.channels(); 189 channels_ = params.channels();
178 sample_rate_ = params.sample_rate(); 190 sample_rate_ = params.sample_rate();
179 191
180 if (!set_format_cb_.is_null()) 192 if (!set_format_cb_.is_null())
181 base::ResetAndReturn(&set_format_cb_).Run(); 193 base::ResetAndReturn(&set_format_cb_).Run();
182 } 194 }
183 195
184 void WebAudioSourceProviderImpl::OnSetFormat() { 196 void WebAudioSourceProviderImpl::OnSetFormat() {
185 base::AutoLock auto_lock(sink_lock_); 197 base::AutoLock auto_lock(sink_lock_);
186 if (!client_) 198 if (!client_)
187 return; 199 return;
188 200
189 // Inform Blink about the audio stream format. 201 // Inform Blink about the audio stream format.
190 client_->setFormat(channels_, sample_rate_); 202 client_->setFormat(channels_, sample_rate_);
191 } 203 }
192 204
193 } // namespace media 205 } // namespace media
OLDNEW
« media/audio/audio_output_device_unittest.cc ('K') | « media/blink/webaudiosourceprovider_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698