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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "media/audio/audio_input_controller.h" | 10 #include "media/audio/audio_input_controller.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 using ::testing::_; | 14 using ::testing::_; |
15 using ::testing::AtLeast; | 15 using ::testing::AtLeast; |
16 using ::testing::Exactly; | 16 using ::testing::Exactly; |
17 using ::testing::InvokeWithoutArgs; | 17 using ::testing::InvokeWithoutArgs; |
18 using ::testing::NotNull; | 18 using ::testing::NotNull; |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 static const int kSampleRate = AudioParameters::kAudioCDSampleRate; | 22 static const int kSampleRate = AudioParameters::kAudioCDSampleRate; |
23 static const int kBitsPerSample = 16; | 23 static const int kBitsPerSample = 16; |
24 static const int kChannels = 2; | 24 static const int kChannels = 2; |
25 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; | 25 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; |
26 static const int kSamplesPerPacket = kSampleRate / 10; | 26 static const int kSamplesPerPacket = kSampleRate / 10; |
27 | 27 |
| 28 // Posts MessageLoop::QuitClosure() on specified message loop. |
28 ACTION_P(QuitMessageLoop, loop_or_proxy) { | 29 ACTION_P(QuitMessageLoop, loop_or_proxy) { |
29 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 30 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
30 } | 31 } |
31 | 32 |
| 33 // Posts MessageLoop::QuitClosure() on specified message loop after a certain |
| 34 // number of calls given by |limit|. |
32 ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop_or_proxy) { | 35 ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop_or_proxy) { |
33 if (++*count >= limit) { | 36 if (++*count >= limit) { |
34 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 37 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
35 } | 38 } |
36 } | 39 } |
37 | 40 |
38 // Closes AudioOutputController synchronously. | 41 // Closes AudioOutputController synchronously. |
39 static void CloseAudioController(AudioInputController* controller) { | 42 static void CloseAudioController(AudioInputController* controller) { |
40 controller->Close(MessageLoop::QuitClosure()); | 43 controller->Close(MessageLoop::QuitClosure()); |
41 MessageLoop::current()->Run(); | 44 MessageLoop::current()->Run(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 controller->Record(); | 218 controller->Record(); |
216 | 219 |
217 controller->Close(MessageLoop::QuitClosure()); | 220 controller->Close(MessageLoop::QuitClosure()); |
218 MessageLoop::current()->Run(); | 221 MessageLoop::current()->Run(); |
219 | 222 |
220 controller->Close(MessageLoop::QuitClosure()); | 223 controller->Close(MessageLoop::QuitClosure()); |
221 MessageLoop::current()->Run(); | 224 MessageLoop::current()->Run(); |
222 } | 225 } |
223 | 226 |
224 } // namespace media | 227 } // namespace media |
OLD | NEW |