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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // Reported render/output delay. Typical value is ~40 [ms]. | 75 // Reported render/output delay. Typical value is ~40 [ms]. |
76 int output_delay_ms; | 76 int output_delay_ms; |
77 }; | 77 }; |
78 | 78 |
79 // This class mocks the platform specific audio manager and overrides | 79 // This class mocks the platform specific audio manager and overrides |
80 // the GetMessageLoop() method to ensure that we can run our tests on | 80 // the GetMessageLoop() method to ensure that we can run our tests on |
81 // the main thread instead of the audio thread. | 81 // the main thread instead of the audio thread. |
82 class MockAudioManager : public AudioManagerAnyPlatform { | 82 class MockAudioManager : public AudioManagerAnyPlatform { |
83 public: | 83 public: |
84 MockAudioManager() { | 84 MockAudioManager() {} |
85 Init(); | |
86 } | |
87 | |
88 virtual ~MockAudioManager() {} | 85 virtual ~MockAudioManager() {} |
89 | 86 |
90 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE { | 87 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE { |
91 return MessageLoop::current()->message_loop_proxy(); | 88 return MessageLoop::current()->message_loop_proxy(); |
92 } | 89 } |
93 | 90 |
94 private: | 91 private: |
95 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 92 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
96 }; | 93 }; |
97 | 94 |
(...skipping 24 matching lines...) Expand all Loading... |
122 DISALLOW_COPY_AND_ASSIGN(AudioLowLatencyInputOutputTest); | 119 DISALLOW_COPY_AND_ASSIGN(AudioLowLatencyInputOutputTest); |
123 }; | 120 }; |
124 | 121 |
125 // This audio source/sink implementation should be used for manual tests | 122 // This audio source/sink implementation should be used for manual tests |
126 // only since delay measurements are stored on an output text file. | 123 // only since delay measurements are stored on an output text file. |
127 // All incoming/recorded audio packets are stored in an intermediate media | 124 // All incoming/recorded audio packets are stored in an intermediate media |
128 // buffer which the renderer reads from when it needs audio for playout. | 125 // buffer which the renderer reads from when it needs audio for playout. |
129 // The total effect is that recorded audio is played out in loop back using | 126 // The total effect is that recorded audio is played out in loop back using |
130 // a sync buffer as temporary storage. | 127 // a sync buffer as temporary storage. |
131 class FullDuplexAudioSinkSource | 128 class FullDuplexAudioSinkSource |
132 | |
133 : public AudioInputStream::AudioInputCallback, | 129 : public AudioInputStream::AudioInputCallback, |
134 public AudioOutputStream::AudioSourceCallback { | 130 public AudioOutputStream::AudioSourceCallback { |
135 public: | 131 public: |
136 FullDuplexAudioSinkSource(int sample_rate, | 132 FullDuplexAudioSinkSource(int sample_rate, |
137 int samples_per_packet, | 133 int samples_per_packet, |
138 int channels) | 134 int channels) |
139 : sample_rate_(sample_rate), | 135 : sample_rate_(sample_rate), |
140 samples_per_packet_(samples_per_packet), | 136 samples_per_packet_(samples_per_packet), |
141 channels_(channels), | 137 channels_(channels), |
142 input_elements_to_write_(0), | 138 input_elements_to_write_(0), |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 468 |
473 // All Close() operations that run on the mocked audio thread, | 469 // All Close() operations that run on the mocked audio thread, |
474 // should be synchronous and not post additional close tasks to | 470 // should be synchronous and not post additional close tasks to |
475 // mocked the audio thread. Hence, there is no need to call | 471 // mocked the audio thread. Hence, there is no need to call |
476 // message_loop()->RunAllPending() after the Close() methods. | 472 // message_loop()->RunAllPending() after the Close() methods. |
477 aos->Close(); | 473 aos->Close(); |
478 ais->Close(); | 474 ais->Close(); |
479 } | 475 } |
480 | 476 |
481 } // namespace media | 477 } // namespace media |
OLD | NEW |