| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 blink_audio_source.setExtraData( | 283 blink_audio_source.setExtraData( |
| 284 new MediaStreamAudioSource(-1, device_info, cb, NULL)); | 284 new MediaStreamAudioSource(-1, device_info, cb, NULL)); |
| 285 blink_track->initialize(blink::WebString::fromUTF8("dummy_track"), | 285 blink_track->initialize(blink::WebString::fromUTF8("dummy_track"), |
| 286 blink_audio_source); | 286 blink_audio_source); |
| 287 blink_track->setExtraData(native_track.release()); | 287 blink_track->setExtraData(native_track.release()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 // Emulates an audio capture device capturing data from the source. | 290 // Emulates an audio capture device capturing data from the source. |
| 291 inline void CaptureAudio(const uint32 buffers) { | 291 inline void CaptureAudio(const uint32 buffers) { |
| 292 for (uint32 i = 0; i < buffers; ++i) | 292 for (uint32 i = 0; i < buffers; ++i) |
| 293 native_track()->Capture(source_data(), | 293 native_track()->Capture(source_data(), false); |
| 294 base::TimeDelta::FromMilliseconds(0), 1, false, | |
| 295 false, false); | |
| 296 } | 294 } |
| 297 | 295 |
| 298 // Used to simulate a problem with sockets. | 296 // Used to simulate a problem with sockets. |
| 299 void SetFailureModeOnForeignSocket(bool in_failure_mode) { | 297 void SetFailureModeOnForeignSocket(bool in_failure_mode) { |
| 300 recognizer()->sending_socket()->SetFailureMode(in_failure_mode); | 298 recognizer()->sending_socket()->SetFailureMode(in_failure_mode); |
| 301 } | 299 } |
| 302 | 300 |
| 303 // Helper method for verifying captured audio data has been consumed. | 301 // Helper method for verifying captured audio data has been consumed. |
| 304 inline void AssertConsumedBuffers(const uint32 buffer_index) { | 302 inline void AssertConsumedBuffers(const uint32 buffer_index) { |
| 305 ASSERT_EQ(buffer_index, recognizer()->GetAudioInputBuffer()->params.size); | 303 ASSERT_EQ(buffer_index, recognizer()->GetAudioInputBuffer()->params.size); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 const uint32 kBuffersPerNotification = Initialize(44100, 441, 16000, 1600); | 503 const uint32 kBuffersPerNotification = Initialize(44100, 441, 16000, 1600); |
| 506 AssertConsumedBuffers(0U); | 504 AssertConsumedBuffers(0U); |
| 507 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); | 505 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); |
| 508 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 506 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
| 509 | 507 |
| 510 native_track()->Stop(); | 508 native_track()->Stop(); |
| 511 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); | 509 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); |
| 512 } | 510 } |
| 513 | 511 |
| 514 } // namespace content | 512 } // namespace content |
| OLD | NEW |