| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/environment.h" | 6 #include "base/environment.h" |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 MockAudioOutputControllerSyncReader sync_reader; | 253 MockAudioOutputControllerSyncReader sync_reader; |
| 254 EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) | 254 EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) |
| 255 .Times(AtLeast(1)); | 255 .Times(AtLeast(1)); |
| 256 EXPECT_CALL(sync_reader, Read(_, _)) | 256 EXPECT_CALL(sync_reader, Read(_, _)) |
| 257 .WillRepeatedly(DoAll(ClearBuffer(), SignalEvent(&event), Return(4))); | 257 .WillRepeatedly(DoAll(ClearBuffer(), SignalEvent(&event), Return(4))); |
| 258 EXPECT_CALL(sync_reader, DataReady()) | 258 EXPECT_CALL(sync_reader, DataReady()) |
| 259 .WillRepeatedly(Return(true)); | 259 .WillRepeatedly(Return(true)); |
| 260 EXPECT_CALL(sync_reader, Close()); | 260 EXPECT_CALL(sync_reader, Close()); |
| 261 | 261 |
| 262 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, | 262 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, kChannelLayout, |
| 263 kSampleRate, kBitsPerSample, kSamplesPerPacket); | 263 kSampleRate, kBitsPerSample, kSamplesPerPacket); |
| 264 scoped_refptr<AudioOutputController> controller = | 264 scoped_refptr<AudioOutputController> controller = |
| 265 AudioOutputController::Create( | 265 AudioOutputController::Create( |
| 266 audio_manager.get(), &event_handler, params, &sync_reader); | 266 audio_manager.get(), &event_handler, params, &sync_reader); |
| 267 ASSERT_TRUE(controller.get()); | 267 ASSERT_TRUE(controller.get()); |
| 268 | 268 |
| 269 // Wait for OnCreated() to be called. | 269 // Wait for OnCreated() to be called. |
| 270 event.Wait(); | 270 event.Wait(); |
| 271 | 271 |
| 272 ASSERT_FALSE(play_event.IsSignaled()); | 272 ASSERT_FALSE(play_event.IsSignaled()); |
| 273 controller->Play(); | 273 controller->Play(); |
| 274 play_event.Wait(); | 274 play_event.Wait(); |
| 275 | 275 |
| 276 // Force a state change and wait for the stream to come back to playing state. | 276 // Force a state change and wait for the stream to come back to playing state. |
| 277 play_event.Reset(); | 277 play_event.Reset(); |
| 278 audio_manager->GetMessageLoop()->PostTask(FROM_HERE, | 278 audio_manager->GetMessageLoop()->PostTask(FROM_HERE, |
| 279 base::Bind(&AudioOutputController::OnDeviceChange, controller)); | 279 base::Bind(&AudioOutputController::OnDeviceChange, controller)); |
| 280 play_event.Wait(); | 280 play_event.Wait(); |
| 281 | 281 |
| 282 // Now stop the controller. | 282 // Now stop the controller. |
| 283 CloseAudioController(controller); | 283 CloseAudioController(controller); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace media | 286 } // namespace media |
| OLD | NEW |