OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/environment.h" | 5 #include "base/environment.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 msg.set_routing_id(kRouteId); | 211 msg.set_routing_id(kRouteId); |
212 | 212 |
213 ViewHostMsg_Audio_CreateStream_Params params; | 213 ViewHostMsg_Audio_CreateStream_Params params; |
214 if (mock_stream_) | 214 if (mock_stream_) |
215 params.params.format = AudioParameters::AUDIO_MOCK; | 215 params.params.format = AudioParameters::AUDIO_MOCK; |
216 else | 216 else |
217 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; | 217 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; |
218 params.params.channels = 2; | 218 params.params.channels = 2; |
219 params.params.sample_rate = AudioParameters::kAudioCDSampleRate; | 219 params.params.sample_rate = AudioParameters::kAudioCDSampleRate; |
220 params.params.bits_per_sample = 16; | 220 params.params.bits_per_sample = 16; |
221 params.packet_size = 0; | 221 params.params.samples_per_packet = 0; |
222 | 222 |
223 // Send a create stream message to the audio output stream and wait until | 223 // Send a create stream message to the audio output stream and wait until |
224 // we receive the created message. | 224 // we receive the created message. |
225 host_->OnCreateStream(msg, kStreamId, params, false); | 225 host_->OnCreateStream(msg, kStreamId, params, false); |
226 message_loop_->Run(); | 226 message_loop_->Run(); |
227 } | 227 } |
228 | 228 |
229 void CreateLowLatency() { | 229 void CreateLowLatency() { |
230 InSequence s; | 230 InSequence s; |
231 // We will first receive a OnLowLatencyStreamCreated() signal. | 231 // We will first receive a OnLowLatencyStreamCreated() signal. |
232 EXPECT_CALL(*host_, | 232 EXPECT_CALL(*host_, |
233 OnLowLatencyStreamCreated(kRouteId, kStreamId, _)) | 233 OnLowLatencyStreamCreated(kRouteId, kStreamId, _)) |
234 .WillOnce(QuitMessageLoop(message_loop_.get())); | 234 .WillOnce(QuitMessageLoop(message_loop_.get())); |
235 | 235 |
236 IPC::Message msg; | 236 IPC::Message msg; |
237 msg.set_routing_id(kRouteId); | 237 msg.set_routing_id(kRouteId); |
238 | 238 |
239 ViewHostMsg_Audio_CreateStream_Params params; | 239 ViewHostMsg_Audio_CreateStream_Params params; |
240 if (mock_stream_) | 240 if (mock_stream_) |
241 params.params.format = AudioParameters::AUDIO_MOCK; | 241 params.params.format = AudioParameters::AUDIO_MOCK; |
242 else | 242 else |
243 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; | 243 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; |
244 params.params.channels = 2; | 244 params.params.channels = 2; |
245 params.params.sample_rate = AudioParameters::kAudioCDSampleRate; | 245 params.params.sample_rate = AudioParameters::kAudioCDSampleRate; |
246 params.params.bits_per_sample = 16; | 246 params.params.bits_per_sample = 16; |
247 params.packet_size = 0; | 247 params.params.samples_per_packet = 0; |
248 | 248 |
249 // Send a create stream message to the audio output stream and wait until | 249 // Send a create stream message to the audio output stream and wait until |
250 // we receive the created message. | 250 // we receive the created message. |
251 host_->OnCreateStream(msg, kStreamId, params, true); | 251 host_->OnCreateStream(msg, kStreamId, params, true); |
252 message_loop_->Run(); | 252 message_loop_->Run(); |
253 } | 253 } |
254 | 254 |
255 void Close() { | 255 void Close() { |
256 // Send a message to AudioRendererHost to tell it we want to close the | 256 // Send a message to AudioRendererHost to tell it we want to close the |
257 // stream. | 257 // stream. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 // Simulate the case where a stream is not properly closed. | 484 // Simulate the case where a stream is not properly closed. |
485 TEST_F(AudioRendererHostTest, CreateLowLatencyAndShutdown) { | 485 TEST_F(AudioRendererHostTest, CreateLowLatencyAndShutdown) { |
486 if (!IsRunningHeadless()) | 486 if (!IsRunningHeadless()) |
487 EnableRealDevice(); | 487 EnableRealDevice(); |
488 | 488 |
489 CreateLowLatency(); | 489 CreateLowLatency(); |
490 } | 490 } |
491 | 491 |
492 // TODO(hclam): Add tests for data conversation in low latency mode. | 492 // TODO(hclam): Add tests for data conversation in low latency mode. |
OLD | NEW |