Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: content/browser/speech/speech_recognition_browsertest.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 static_cast<uint8_t>(127 * sin(i * 3.14F / (16 * buffer_size))); 154 static_cast<uint8_t>(127 * sin(i * 3.14F / (16 * buffer_size)));
155 } else { 155 } else {
156 memset(audio_buffer.get(), 0, buffer_size); 156 memset(audio_buffer.get(), 0, buffer_size);
157 } 157 }
158 158
159 std::unique_ptr<media::AudioBus> audio_bus = 159 std::unique_ptr<media::AudioBus> audio_bus =
160 media::AudioBus::Create(audio_params); 160 media::AudioBus::Create(audio_params);
161 audio_bus->FromInterleaved(&audio_buffer.get()[0], 161 audio_bus->FromInterleaved(&audio_buffer.get()[0],
162 audio_bus->frames(), 162 audio_bus->frames(),
163 audio_params.bits_per_sample() / 8); 163 audio_params.bits_per_sample() / 8);
164 controller->sync_writer()->Write(audio_bus.get(), 0.0, false, 0); 164 controller->sync_writer()->Write(audio_bus.get(), 0.0, false,
165 base::TimeDelta(), base::TimeTicks::Now());
165 } 166 }
166 167
167 void FeedAudioController(int duration_ms, bool feed_with_noise) { 168 void FeedAudioController(int duration_ms, bool feed_with_noise) {
168 media::TestAudioInputController* controller = 169 media::TestAudioInputController* controller =
169 test_audio_input_controller_factory_.controller(); 170 test_audio_input_controller_factory_.controller();
170 ASSERT_TRUE(controller); 171 ASSERT_TRUE(controller);
171 const media::AudioParameters& audio_params = controller->audio_parameters(); 172 const media::AudioParameters& audio_params = controller->audio_parameters();
172 const size_t buffer_size = audio_params.GetBytesPerBuffer(); 173 const size_t buffer_size = audio_params.GetBytesPerBuffer();
173 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 / 174 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 /
174 audio_params.sample_rate(); 175 audio_params.sample_rate();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 215
215 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { 216 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) {
216 NavigateToURLBlockUntilNavigationsComplete( 217 NavigateToURLBlockUntilNavigationsComplete(
217 shell(), GetTestUrlFromFragment("oneshot"), 2); 218 shell(), GetTestUrlFromFragment("oneshot"), 2);
218 219
219 EXPECT_EQ(kClientDisconnected, streaming_server_state()); 220 EXPECT_EQ(kClientDisconnected, streaming_server_state());
220 EXPECT_EQ("goodresult1", GetPageFragment()); 221 EXPECT_EQ("goodresult1", GetPageFragment());
221 } 222 }
222 223
223 } // namespace content 224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698