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

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

Issue 2624403002: Refactor AudioInputController and related interfaces. (Closed)
Patch Set: Address comments Created 3 years, 11 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 static_cast<uint8_t>(127 * sin(i * 3.14F / (16 * buffer_size))); 149 static_cast<uint8_t>(127 * sin(i * 3.14F / (16 * buffer_size)));
150 } else { 150 } else {
151 memset(audio_buffer.get(), 0, buffer_size); 151 memset(audio_buffer.get(), 0, buffer_size);
152 } 152 }
153 153
154 std::unique_ptr<media::AudioBus> audio_bus = 154 std::unique_ptr<media::AudioBus> audio_bus =
155 media::AudioBus::Create(audio_params); 155 media::AudioBus::Create(audio_params);
156 audio_bus->FromInterleaved(&audio_buffer.get()[0], 156 audio_bus->FromInterleaved(&audio_buffer.get()[0],
157 audio_bus->frames(), 157 audio_bus->frames(),
158 audio_params.bits_per_sample() / 8); 158 audio_params.bits_per_sample() / 8);
159 controller->event_handler()->OnData(controller.get(), audio_bus.get()); 159 controller->sync_writer()->Write(audio_bus.get(), 0.0, false, 0);
160 } 160 }
161 161
162 void FeedAudioController(int duration_ms, bool feed_with_noise) { 162 void FeedAudioController(int duration_ms, bool feed_with_noise) {
163 media::TestAudioInputController* controller = 163 media::TestAudioInputController* controller =
164 test_audio_input_controller_factory_.controller(); 164 test_audio_input_controller_factory_.controller();
165 ASSERT_TRUE(controller); 165 ASSERT_TRUE(controller);
166 const media::AudioParameters& audio_params = controller->audio_parameters(); 166 const media::AudioParameters& audio_params = controller->audio_parameters();
167 const size_t buffer_size = audio_params.GetBytesPerBuffer(); 167 const size_t buffer_size = audio_params.GetBytesPerBuffer();
168 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 / 168 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 /
169 audio_params.sample_rate(); 169 audio_params.sample_rate();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { 208 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) {
209 NavigateToURLBlockUntilNavigationsComplete( 209 NavigateToURLBlockUntilNavigationsComplete(
210 shell(), GetTestUrlFromFragment("oneshot"), 2); 210 shell(), GetTestUrlFromFragment("oneshot"), 2);
211 211
212 EXPECT_EQ(kClientDisconnected, streaming_server_state()); 212 EXPECT_EQ(kClientDisconnected, streaming_server_state());
213 EXPECT_EQ("goodresult1", GetPageFragment()); 213 EXPECT_EQ("goodresult1", GetPageFragment());
214 } 214 }
215 215
216 } // namespace content 216 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698