| 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 base::WaitableEvent closed_event(true, false); | 43 base::WaitableEvent closed_event(true, false); |
| 41 controller->Close(base::Bind(&base::WaitableEvent::Signal, | 44 controller->Close(base::Bind(&base::WaitableEvent::Signal, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 225 |
| 223 base::WaitableEvent closed_event_2(true, false); | 226 base::WaitableEvent closed_event_2(true, false); |
| 224 controller->Close(base::Bind(&base::WaitableEvent::Signal, | 227 controller->Close(base::Bind(&base::WaitableEvent::Signal, |
| 225 base::Unretained(&closed_event_2))); | 228 base::Unretained(&closed_event_2))); |
| 226 | 229 |
| 227 closed_event_1.Wait(); | 230 closed_event_1.Wait(); |
| 228 closed_event_2.Wait(); | 231 closed_event_2.Wait(); |
| 229 } | 232 } |
| 230 | 233 |
| 231 } // namespace media | 234 } // namespace media |
| OLD | NEW |