| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Initializes the producer and consumer with specified audio parameters. | 207 // Initializes the producer and consumer with specified audio parameters. |
| 208 // Returns the minimal number of input audio buffers which need to be captured | 208 // Returns the minimal number of input audio buffers which need to be captured |
| 209 // before they get sent to the consumer. | 209 // before they get sent to the consumer. |
| 210 uint32 Initialize(int input_sample_rate, | 210 uint32 Initialize(int input_sample_rate, |
| 211 int input_frames_per_buffer, | 211 int input_frames_per_buffer, |
| 212 int output_sample_rate, | 212 int output_sample_rate, |
| 213 int output_frames_per_buffer) { | 213 int output_frames_per_buffer) { |
| 214 // Audio Environment setup. | 214 // Audio Environment setup. |
| 215 source_params_.Reset(kInputFormat, | 215 source_params_.Reset(kInputFormat, |
| 216 kInputChannelLayout, | 216 kInputChannelLayout, |
| 217 kInputChannels, | |
| 218 input_sample_rate, | 217 input_sample_rate, |
| 219 kInputBitsPerSample, | 218 kInputBitsPerSample, |
| 220 input_frames_per_buffer); | 219 input_frames_per_buffer); |
| 221 sink_params_.Reset(kOutputFormat, | 220 sink_params_.Reset(kOutputFormat, |
| 222 kOutputChannelLayout, | 221 kOutputChannelLayout, |
| 223 kOutputChannels, | |
| 224 output_sample_rate, | 222 output_sample_rate, |
| 225 kOutputBitsPerSample, | 223 kOutputBitsPerSample, |
| 226 output_frames_per_buffer); | 224 output_frames_per_buffer); |
| 227 source_bus_ = | 225 source_bus_ = |
| 228 media::AudioBus::Create(kInputChannels, input_frames_per_buffer); | 226 media::AudioBus::Create(kInputChannels, input_frames_per_buffer); |
| 229 source_bus_->Zero(); | 227 source_bus_->Zero(); |
| 230 first_frame_capture_time_ = base::TimeTicks::Now(); | 228 first_frame_capture_time_ = base::TimeTicks::Now(); |
| 231 sample_frames_captured_ = 0; | 229 sample_frames_captured_ = 0; |
| 232 | 230 |
| 233 // Prepare the track and audio source. | 231 // Prepare the track and audio source. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 const uint32 buffers_per_notification = Initialize(44100, 441, 16000, 1600); | 519 const uint32 buffers_per_notification = Initialize(44100, 441, 16000, 1600); |
| 522 AssertConsumedBuffers(0U); | 520 AssertConsumedBuffers(0U); |
| 523 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 521 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
| 524 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 522 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
| 525 | 523 |
| 526 native_track()->Stop(); | 524 native_track()->Stop(); |
| 527 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 525 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
| 528 } | 526 } |
| 529 | 527 |
| 530 } // namespace content | 528 } // namespace content |
| OLD | NEW |