| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ | 5 #ifndef MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ |
| 6 #define MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ | 6 #define MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 int dest_frame_offset, | 50 int dest_frame_offset, |
| 51 AudioBus* dest); | 51 AudioBus* dest); |
| 52 | 52 |
| 53 // Moves the current position forward by |frames| frames. If |frames| exceeds | 53 // Moves the current position forward by |frames| frames. If |frames| exceeds |
| 54 // frames available, the seek operation will fail. | 54 // frames available, the seek operation will fail. |
| 55 void SeekFrames(int frames); | 55 void SeekFrames(int frames); |
| 56 | 56 |
| 57 // Returns the number of frames buffered beyond the current position. | 57 // Returns the number of frames buffered beyond the current position. |
| 58 int frames() const { return frames_; } | 58 int frames() const { return frames_; } |
| 59 | 59 |
| 60 // Returns the current timestamp, taking into account current offset. The | |
| 61 // value calculated based on the timestamp of the current buffer. If timestamp | |
| 62 // for the current buffer is set to 0, then returns value that corresponds to | |
| 63 // the last position in a buffer that had timestamp set. kNoTimestamp() is | |
| 64 // returned if no buffers we read from had timestamp set. | |
| 65 base::TimeDelta current_time() const { return current_time_; } | |
| 66 | |
| 67 private: | 60 private: |
| 68 // Definition of the buffer queue. | 61 // Definition of the buffer queue. |
| 69 typedef std::deque<scoped_refptr<AudioBuffer> > BufferQueue; | 62 typedef std::deque<scoped_refptr<AudioBuffer> > BufferQueue; |
| 70 | 63 |
| 71 // An internal method shared by ReadFrames() and SeekFrames() that actually | 64 // An internal method shared by ReadFrames() and SeekFrames() that actually |
| 72 // does reading. It reads a maximum of |frames| frames into |dest|. Returns | 65 // does reading. It reads a maximum of |frames| frames into |dest|. Returns |
| 73 // the number of frames read. The current position will be moved forward by | 66 // the number of frames read. The current position will be moved forward by |
| 74 // the number of frames read if |advance_position| is set. If |dest| is NULL, | 67 // the number of frames read if |advance_position| is set. If |dest| is NULL, |
| 75 // only the current position will advance but no data will be copied. | 68 // only the current position will advance but no data will be copied. |
| 76 // |source_frame_offset| can be used to skip frames before reading. | 69 // |source_frame_offset| can be used to skip frames before reading. |
| 77 // |dest_frame_offset| specifies a starting offset into |dest|. | 70 // |dest_frame_offset| specifies a starting offset into |dest|. |
| 78 int InternalRead(int frames, | 71 int InternalRead(int frames, |
| 79 bool advance_position, | 72 bool advance_position, |
| 80 int source_frame_offset, | 73 int source_frame_offset, |
| 81 int dest_frame_offset, | 74 int dest_frame_offset, |
| 82 AudioBus* dest); | 75 AudioBus* dest); |
| 83 | 76 |
| 84 // Updates |current_time_| with the time that corresponds to the specified | |
| 85 // position in the buffer. | |
| 86 void UpdateCurrentTime(BufferQueue::iterator buffer, int offset); | |
| 87 | |
| 88 BufferQueue::iterator current_buffer_; | 77 BufferQueue::iterator current_buffer_; |
| 89 BufferQueue buffers_; | 78 BufferQueue buffers_; |
| 90 int current_buffer_offset_; | 79 int current_buffer_offset_; |
| 91 | 80 |
| 92 // Number of frames available to be read in the buffer. | 81 // Number of frames available to be read in the buffer. |
| 93 int frames_; | 82 int frames_; |
| 94 | 83 |
| 95 // Keeps track of the most recent time we've seen in case the |buffers_| is | |
| 96 // empty when our owner asks what time it is. | |
| 97 base::TimeDelta current_time_; | |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(AudioBufferQueue); | 84 DISALLOW_COPY_AND_ASSIGN(AudioBufferQueue); |
| 100 }; | 85 }; |
| 101 | 86 |
| 102 } // namespace media | 87 } // namespace media |
| 103 | 88 |
| 104 #endif // MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ | 89 #endif // MEDIA_BASE_AUDIO_BUFFER_QUEUE_H_ |
| OLD | NEW |