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 <windows.h> | 5 #include <windows.h> |
6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Used to terminate a loop from a different thread than the loop belongs to. | 59 // Used to terminate a loop from a different thread than the loop belongs to. |
60 // |loop| should be a MessageLoopProxy. | 60 // |loop| should be a MessageLoopProxy. |
61 ACTION_P(QuitLoop, loop) { | 61 ACTION_P(QuitLoop, loop) { |
62 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 62 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
63 } | 63 } |
64 | 64 |
65 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { | 65 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { |
66 public: | 66 public: |
67 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, | 67 MOCK_METHOD2(OnMoreData, int(AudioBus* audio_bus, |
68 AudioBuffersState buffers_state)); | 68 AudioBuffersState buffers_state)); |
| 69 MOCK_METHOD3(OnMoreIOData, int(AudioBus* source, |
| 70 AudioBus* dest, |
| 71 AudioBuffersState buffers_state)); |
69 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); | 72 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); |
70 }; | 73 }; |
71 | 74 |
72 // This audio source implementation should be used for manual tests only since | 75 // This audio source implementation should be used for manual tests only since |
73 // it takes about 20 seconds to play out a file. | 76 // it takes about 20 seconds to play out a file. |
74 class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { | 77 class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { |
75 public: | 78 public: |
76 explicit ReadFromFileAudioSource(const std::string& name) | 79 explicit ReadFromFileAudioSource(const std::string& name) |
77 : pos_(0), | 80 : pos_(0), |
78 previous_call_time_(base::Time::Now()), | 81 previous_call_time_(base::Time::Now()), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 max_size = file_size() - pos_; | 133 max_size = file_size() - pos_; |
131 int frames = max_size / (audio_bus->channels() * kBitsPerSample / 8); | 134 int frames = max_size / (audio_bus->channels() * kBitsPerSample / 8); |
132 if (max_size) { | 135 if (max_size) { |
133 audio_bus->FromInterleaved( | 136 audio_bus->FromInterleaved( |
134 file_->GetData() + pos_, frames, kBitsPerSample / 8); | 137 file_->GetData() + pos_, frames, kBitsPerSample / 8); |
135 pos_ += max_size; | 138 pos_ += max_size; |
136 } | 139 } |
137 return frames; | 140 return frames; |
138 } | 141 } |
139 | 142 |
| 143 virtual int OnMoreIOData(AudioBus* source, |
| 144 AudioBus* dest, |
| 145 AudioBuffersState buffers_state) OVERRIDE { |
| 146 NOTREACHED(); |
| 147 return 0; |
| 148 } |
| 149 |
140 virtual void OnError(AudioOutputStream* stream, int code) {} | 150 virtual void OnError(AudioOutputStream* stream, int code) {} |
141 | 151 |
142 int file_size() { return file_->GetDataSize(); } | 152 int file_size() { return file_->GetDataSize(); } |
143 | 153 |
144 private: | 154 private: |
145 scoped_refptr<DecoderBuffer> file_; | 155 scoped_refptr<DecoderBuffer> file_; |
146 scoped_array<int> delta_times_; | 156 scoped_array<int> delta_times_; |
147 int pos_; | 157 int pos_; |
148 base::Time previous_call_time_; | 158 base::Time previous_call_time_; |
149 FILE* text_file_; | 159 FILE* text_file_; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 | 849 |
840 aos->Start(&source); | 850 aos->Start(&source); |
841 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), | 851 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), |
842 TestTimeouts::action_timeout()); | 852 TestTimeouts::action_timeout()); |
843 loop.Run(); | 853 loop.Run(); |
844 aos->Stop(); | 854 aos->Stop(); |
845 aos->Close(); | 855 aos->Close(); |
846 } | 856 } |
847 | 857 |
848 } // namespace media | 858 } // namespace media |
OLD | NEW |