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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 int max_size = | 127 int max_size = |
128 audio_bus->frames() * audio_bus->channels() * kBitsPerSample / 8; | 128 audio_bus->frames() * audio_bus->channels() * kBitsPerSample / 8; |
129 | 129 |
130 // Use samples read from a data file and fill up the audio buffer | 130 // Use samples read from a data file and fill up the audio buffer |
131 // provided to us in the callback. | 131 // provided to us in the callback. |
132 if (pos_ + static_cast<int>(max_size) > file_size()) | 132 if (pos_ + static_cast<int>(max_size) > file_size()) |
133 max_size = file_size() - pos_; | 133 max_size = file_size() - pos_; |
134 int frames = max_size / (audio_bus->channels() * kBitsPerSample / 8); | 134 int frames = max_size / (audio_bus->channels() * kBitsPerSample / 8); |
135 if (max_size) { | 135 if (max_size) { |
136 audio_bus->FromInterleaved( | 136 audio_bus->FromInterleaved( |
137 file_->GetData() + pos_, frames, kBitsPerSample / 8); | 137 file_->data() + pos_, frames, kBitsPerSample / 8); |
138 pos_ += max_size; | 138 pos_ += max_size; |
139 } | 139 } |
140 return frames; | 140 return frames; |
141 } | 141 } |
142 | 142 |
143 virtual int OnMoreIOData(AudioBus* source, | 143 virtual int OnMoreIOData(AudioBus* source, |
144 AudioBus* dest, | 144 AudioBus* dest, |
145 AudioBuffersState buffers_state) OVERRIDE { | 145 AudioBuffersState buffers_state) OVERRIDE { |
146 NOTREACHED(); | 146 NOTREACHED(); |
147 return 0; | 147 return 0; |
148 } | 148 } |
149 | 149 |
150 virtual void OnError(AudioOutputStream* stream) {} | 150 virtual void OnError(AudioOutputStream* stream) {} |
151 | 151 |
152 int file_size() { return file_->GetDataSize(); } | 152 int file_size() { return file_->data_size(); } |
153 | 153 |
154 private: | 154 private: |
155 scoped_refptr<DecoderBuffer> file_; | 155 scoped_refptr<DecoderBuffer> file_; |
156 scoped_ptr<int[]> delta_times_; | 156 scoped_ptr<int[]> delta_times_; |
157 int pos_; | 157 int pos_; |
158 base::TimeTicks previous_call_time_; | 158 base::TimeTicks previous_call_time_; |
159 FILE* text_file_; | 159 FILE* text_file_; |
160 size_t elements_to_write_; | 160 size_t elements_to_write_; |
161 }; | 161 }; |
162 | 162 |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 694 |
695 aos->Start(&source); | 695 aos->Start(&source); |
696 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), | 696 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), |
697 TestTimeouts::action_timeout()); | 697 TestTimeouts::action_timeout()); |
698 loop.Run(); | 698 loop.Run(); |
699 aos->Stop(); | 699 aos->Stop(); |
700 aos->Close(); | 700 aos->Close(); |
701 } | 701 } |
702 | 702 |
703 } // namespace media | 703 } // namespace media |
OLD | NEW |