OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/speech_recognition_audio_sink.h" | 5 #include "content/renderer/media/speech_recognition_audio_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/renderer/media/media_stream_audio_source.h" | 9 #include "content/renderer/media/media_stream_audio_source.h" |
10 #include "content/renderer/media/mock_media_constraint_factory.h" | 10 #include "content/renderer/media/mock_media_constraint_factory.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 kInputBitsPerSample, | 219 kInputBitsPerSample, |
220 input_frames_per_buffer); | 220 input_frames_per_buffer); |
221 sink_params_.Reset(kOutputFormat, | 221 sink_params_.Reset(kOutputFormat, |
222 kOutputChannelLayout, | 222 kOutputChannelLayout, |
223 kOutputChannels, | 223 kOutputChannels, |
224 output_sample_rate, | 224 output_sample_rate, |
225 kOutputBitsPerSample, | 225 kOutputBitsPerSample, |
226 output_frames_per_buffer); | 226 output_frames_per_buffer); |
227 source_bus_ = | 227 source_bus_ = |
228 media::AudioBus::Create(kInputChannels, input_frames_per_buffer); | 228 media::AudioBus::Create(kInputChannels, input_frames_per_buffer); |
| 229 source_bus_->Zero(); |
229 first_frame_capture_time_ = base::TimeTicks::Now(); | 230 first_frame_capture_time_ = base::TimeTicks::Now(); |
230 sample_frames_captured_ = 0; | 231 sample_frames_captured_ = 0; |
231 | 232 |
232 // Prepare the track and audio source. | 233 // Prepare the track and audio source. |
233 blink::WebMediaStreamTrack blink_track; | 234 blink::WebMediaStreamTrack blink_track; |
234 PrepareBlinkTrackOfType(MEDIA_DEVICE_AUDIO_CAPTURE, &blink_track); | 235 PrepareBlinkTrackOfType(MEDIA_DEVICE_AUDIO_CAPTURE, &blink_track); |
235 | 236 |
236 // Get the native track from the blink track and initialize. | 237 // Get the native track from the blink track and initialize. |
237 native_track_ = | 238 native_track_ = |
238 static_cast<WebRtcLocalAudioTrack*>(blink_track.extraData()); | 239 static_cast<WebRtcLocalAudioTrack*>(blink_track.extraData()); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 const uint32 buffers_per_notification = Initialize(44100, 441, 16000, 1600); | 521 const uint32 buffers_per_notification = Initialize(44100, 441, 16000, 1600); |
521 AssertConsumedBuffers(0U); | 522 AssertConsumedBuffers(0U); |
522 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 523 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
523 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 524 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
524 | 525 |
525 native_track()->Stop(); | 526 native_track()->Stop(); |
526 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 527 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
527 } | 528 } |
528 | 529 |
529 } // namespace content | 530 } // namespace content |
OLD | NEW |