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/environment.h" | 6 #include "base/environment.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "media/audio/audio_io.h" | 12 #include "media/audio/audio_io.h" |
13 #include "media/audio/audio_manager_base.h" | 13 #include "media/audio/audio_manager_base.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 // This class allows to find out if the callbacks are occurring as | 18 // This class allows to find out if the callbacks are occurring as |
19 // expected and if any error has been reported. | 19 // expected and if any error has been reported. |
20 class TestInputCallback : public AudioInputStream::AudioInputCallback { | 20 class TestInputCallback : public AudioInputStream::AudioInputCallback { |
21 public: | 21 public: |
22 explicit TestInputCallback() | 22 explicit TestInputCallback() |
23 : callback_count_(0), | 23 : callback_count_(0), |
24 had_error_(0) { | 24 had_error_(0) { |
25 } | 25 } |
26 virtual void OnData(AudioInputStream* stream, | 26 virtual void OnData(AudioInputStream* stream, |
27 const uint8* data, | 27 const AudioBus* source, |
28 uint32 size, | |
29 uint32 hardware_delay_bytes, | 28 uint32 hardware_delay_bytes, |
30 double volume) OVERRIDE { | 29 double volume) OVERRIDE { |
31 ++callback_count_; | 30 ++callback_count_; |
32 } | 31 } |
33 virtual void OnError(AudioInputStream* stream) OVERRIDE { | 32 virtual void OnError(AudioInputStream* stream) OVERRIDE { |
34 ++had_error_; | 33 ++had_error_; |
35 } | 34 } |
36 // Returns how many times OnData() has been called. | 35 // Returns how many times OnData() has been called. |
37 int callback_count() const { | 36 int callback_count() const { |
38 return callback_count_; | 37 return callback_count_; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 base::MessageLoop::QuitClosure(), | 234 base::MessageLoop::QuitClosure(), |
236 base::TimeDelta::FromMilliseconds(500)); | 235 base::TimeDelta::FromMilliseconds(500)); |
237 message_loop_.Run(); | 236 message_loop_.Run(); |
238 EXPECT_GE(test_callback.callback_count(), 2); | 237 EXPECT_GE(test_callback.callback_count(), 2); |
239 EXPECT_FALSE(test_callback.had_error()); | 238 EXPECT_FALSE(test_callback.had_error()); |
240 | 239 |
241 StopAndCloseAudioInputStreamOnAudioThread(); | 240 StopAndCloseAudioInputStreamOnAudioThread(); |
242 } | 241 } |
243 | 242 |
244 } // namespace media | 243 } // namespace media |
OLD | NEW |