| 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 "content/renderer/media/webrtc_local_audio_source_provider.h" | 5 #include "content/renderer/media/webrtc_local_audio_source_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
| 9 #include "media/audio/audio_parameters.h" | 9 #include "media/audio/audio_parameters.h" |
| 10 #include "media/base/audio_fifo.h" | 10 #include "media/base/audio_fifo.h" |
| 11 #include "media/base/audio_hardware_config.h" | 11 #include "media/base/audio_hardware_config.h" |
| 12 #include "third_party/WebKit/public/web/WebAudioSourceProviderClient.h" | 12 #include "third_party/WebKit/public/web/WebAudioSourceProviderClient.h" |
| 13 | 13 |
| 14 using WebKit::WebVector; | 14 using blink::WebVector; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 static const size_t kMaxNumberOfBuffers = 10; | 18 static const size_t kMaxNumberOfBuffers = 10; |
| 19 | 19 |
| 20 // Size of the buffer that WebAudio processes each time, it is the same value | 20 // Size of the buffer that WebAudio processes each time, it is the same value |
| 21 // as AudioNode::ProcessingSizeInFrames in WebKit. | 21 // as AudioNode::ProcessingSizeInFrames in WebKit. |
| 22 // static | 22 // static |
| 23 const size_t WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize = 128; | 23 const size_t WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize = 128; |
| 24 | 24 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 elapsed_ms = static_cast<int>( | 100 elapsed_ms = static_cast<int>( |
| 101 (base::TimeTicks::Now() - last_fill_).InMilliseconds()); | 101 (base::TimeTicks::Now() - last_fill_).InMilliseconds()); |
| 102 } | 102 } |
| 103 *delay_ms = audio_delay_ms_ + elapsed_ms + static_cast<int>( | 103 *delay_ms = audio_delay_ms_ + elapsed_ms + static_cast<int>( |
| 104 1000 * fifo_->frames() / source_params_.sample_rate() + 0.5); | 104 1000 * fifo_->frames() / source_params_.sample_rate() + 0.5); |
| 105 *volume = volume_; | 105 *volume = volume_; |
| 106 *key_pressed = key_pressed_; | 106 *key_pressed = key_pressed_; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void WebRtcLocalAudioSourceProvider::setClient( | 109 void WebRtcLocalAudioSourceProvider::setClient( |
| 110 WebKit::WebAudioSourceProviderClient* client) { | 110 blink::WebAudioSourceProviderClient* client) { |
| 111 NOTREACHED(); | 111 NOTREACHED(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void WebRtcLocalAudioSourceProvider::provideInput( | 114 void WebRtcLocalAudioSourceProvider::provideInput( |
| 115 const WebVector<float*>& audio_data, size_t number_of_frames) { | 115 const WebVector<float*>& audio_data, size_t number_of_frames) { |
| 116 DCHECK_EQ(number_of_frames, kWebAudioRenderBufferSize); | 116 DCHECK_EQ(number_of_frames, kWebAudioRenderBufferSize); |
| 117 if (!bus_wrapper_ || | 117 if (!bus_wrapper_ || |
| 118 static_cast<size_t>(bus_wrapper_->channels()) != audio_data.size()) { | 118 static_cast<size_t>(bus_wrapper_->channels()) != audio_data.size()) { |
| 119 bus_wrapper_ = media::AudioBus::CreateWrapper(audio_data.size()); | 119 bus_wrapper_ = media::AudioBus::CreateWrapper(audio_data.size()); |
| 120 } | 120 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 return 1.0; | 146 return 1.0; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void WebRtcLocalAudioSourceProvider::SetSinkParamsForTesting( | 149 void WebRtcLocalAudioSourceProvider::SetSinkParamsForTesting( |
| 150 const media::AudioParameters& sink_params) { | 150 const media::AudioParameters& sink_params) { |
| 151 DCHECK(thread_checker_.CalledOnValidThread()); | 151 DCHECK(thread_checker_.CalledOnValidThread()); |
| 152 sink_params_ = sink_params; | 152 sink_params_ = sink_params; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace content | 155 } // namespace content |
| OLD | NEW |