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

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

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… 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 base::Callback<void(int)>& callback) {
170 base::AutoLock auto_lock(sink_lock_);
171 if (!client_)
172 sink_->SwitchOutputDevice(device_id, security_origin, callback);
173 }
174
166 void WebAudioSourceProviderImpl::Initialize( 175 void WebAudioSourceProviderImpl::Initialize(
167 const AudioParameters& params, 176 const AudioParameters& params,
168 RenderCallback* renderer) { 177 RenderCallback* renderer) {
169 base::AutoLock auto_lock(sink_lock_); 178 base::AutoLock auto_lock(sink_lock_);
170 CHECK(!renderer_); 179 CHECK(!renderer_);
171 renderer_ = renderer; 180 renderer_ = renderer;
172 181
173 DCHECK_EQ(state_, kStopped); 182 DCHECK_EQ(state_, kStopped);
174 sink_->Initialize(params, renderer); 183 sink_->Initialize(params, renderer);
175 184
176 // Keep track of the format in case the client hasn't yet been set. 185 // Keep track of the format in case the client hasn't yet been set.
177 channels_ = params.channels(); 186 channels_ = params.channels();
178 sample_rate_ = params.sample_rate(); 187 sample_rate_ = params.sample_rate();
179 188
180 if (!set_format_cb_.is_null()) 189 if (!set_format_cb_.is_null())
181 base::ResetAndReturn(&set_format_cb_).Run(); 190 base::ResetAndReturn(&set_format_cb_).Run();
182 } 191 }
183 192
184 void WebAudioSourceProviderImpl::OnSetFormat() { 193 void WebAudioSourceProviderImpl::OnSetFormat() {
185 base::AutoLock auto_lock(sink_lock_); 194 base::AutoLock auto_lock(sink_lock_);
186 if (!client_) 195 if (!client_)
187 return; 196 return;
188 197
189 // Inform Blink about the audio stream format. 198 // Inform Blink about the audio stream format.
190 client_->setFormat(channels_, sample_rate_); 199 client_->setFormat(channels_, sample_rate_);
191 } 200 }
192 201
193 } // namespace media 202 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698