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