OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/filters/audio_file_reader.h" | 5 #include "media/filters/audio_file_reader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return false; | 173 return false; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 current_frame += frames_read; | 177 current_frame += frames_read; |
178 } | 178 } |
179 | 179 |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 InMemoryDataReader::InMemoryDataReader(const char* data, int64 size) | |
184 : data_(data), | |
185 size_(size), | |
186 position_(0) { | |
187 } | |
188 | |
189 int InMemoryDataReader::Read(int size, uint8* data) { | |
190 if (size < 0) | |
191 return -1; | |
192 | |
193 int available_bytes = static_cast<int>(size_ - position_); | |
194 if (size > available_bytes) | |
195 size = available_bytes; | |
196 | |
197 memcpy(data, data_ + position_, size); | |
198 position_ += size; | |
199 return size; | |
200 } | |
201 | |
202 bool InMemoryDataReader::GetPosition(int64* position_out) { | |
203 if (position_out) | |
204 *position_out = position_; | |
205 return true; | |
206 } | |
207 | |
208 bool InMemoryDataReader::SetPosition(int64 position) { | |
209 if (position >= size_) | |
210 return false; | |
211 position_ = position; | |
212 return true; | |
213 } | |
214 | |
215 bool InMemoryDataReader::GetSize(int64* size_out) { | |
216 if (size_out) | |
217 *size_out = size_; | |
218 return true; | |
219 } | |
220 | |
221 bool InMemoryDataReader::IsStreaming() { | |
222 return false; | |
223 } | |
224 | |
225 } // namespace media | 183 } // namespace media |
OLD | NEW |