Chromium Code Reviews| Index: content/renderer/media/webaudiosourceprovider_impl.cc |
| diff --git a/content/renderer/media/webaudiosourceprovider_impl.cc b/content/renderer/media/webaudiosourceprovider_impl.cc |
| index b722a33af4c18e3073fcea36576f1775234a440e..52501f0f276236b109be3eba085ee63608babba6 100644 |
| --- a/content/renderer/media/webaudiosourceprovider_impl.cc |
| +++ b/content/renderer/media/webaudiosourceprovider_impl.cc |
| @@ -87,18 +87,18 @@ void WebAudioSourceProviderImpl::setClient( |
| void WebAudioSourceProviderImpl::provideInput( |
| const WebVector<float*>& audio_data, size_t number_of_frames) { |
| - if (!bus_wrapper_ || |
| - static_cast<size_t>(bus_wrapper_->channels()) != audio_data.size()) { |
| - bus_wrapper_ = media::AudioBus::CreateWrapper(audio_data.size()); |
| - } |
| - |
| - bus_wrapper_->set_frames(number_of_frames); |
| - for (size_t i = 0; i < audio_data.size(); ++i) |
| - bus_wrapper_->SetChannelData(i, audio_data[i]); |
| - |
| // Use a try lock to avoid contention in the real-time audio thread. |
| AutoTryLock auto_try_lock(sink_lock_); |
| - if (!auto_try_lock.locked() || state_ != kPlaying) { |
| + if (auto_try_lock.locked() && state_ == kPlaying) { |
| + if (!bus_wrapper_ || |
| + static_cast<size_t>(bus_wrapper_->channels()) != audio_data.size()) { |
| + bus_wrapper_ = media::AudioBus::CreateWrapper(audio_data.size()); |
| + } |
| + |
| + bus_wrapper_->set_frames(number_of_frames); |
| + for (size_t i = 0; i < audio_data.size(); ++i) |
| + bus_wrapper_->SetChannelData(i, audio_data[i]); |
| + } else { |
| // Provide silence if we failed to acquire the lock or the source is not |
| // running. |
| bus_wrapper_->Zero(); |
|
Ken Russell (switch to Gerrit)
2013/09/04 17:09:36
This looks wrong. If the trylock fails, then now,
|