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 // AudioRendererBase takes care of the tricky queuing work and provides simple | 5 // AudioRendererBase takes care of the tricky queuing work and provides simple |
6 // methods for subclasses to peek and poke at audio data. In addition to | 6 // methods for subclasses to peek and poke at audio data. In addition to |
7 // AudioRenderer interface methods this classes doesn't implement, subclasses | 7 // AudioRenderer interface methods this classes doesn't implement, subclasses |
8 // must also implement the following methods: | 8 // must also implement the following methods: |
9 // OnInitialized | 9 // OnInitialized |
10 // OnStop | 10 // OnStop |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 private: | 93 private: |
94 friend class AudioRendererBaseTest; | 94 friend class AudioRendererBaseTest; |
95 | 95 |
96 // Helper method that schedules an asynchronous read from the decoder and | 96 // Helper method that schedules an asynchronous read from the decoder and |
97 // increments |pending_reads_|. | 97 // increments |pending_reads_|. |
98 // | 98 // |
99 // Safe to call from any thread. | 99 // Safe to call from any thread. |
100 void ScheduleRead_Locked(); | 100 void ScheduleRead_Locked(); |
101 | 101 |
| 102 // Returns true if the data in the buffer is all before |
| 103 // |seek_timestamp_|. This can only return true while |
| 104 // in the kSeeking state. |
| 105 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer); |
| 106 |
| 107 // Enqueues |buffer| in |algorithm_| if it is non-NULL and |
| 108 // buffer->IsEndOfStream() returns false. |
| 109 void EnqueueBuffer(const scoped_refptr<Buffer>& buffer); |
| 110 |
102 // Audio decoder. | 111 // Audio decoder. |
103 scoped_refptr<AudioDecoder> decoder_; | 112 scoped_refptr<AudioDecoder> decoder_; |
104 | 113 |
105 // Algorithm for scaling audio. | 114 // Algorithm for scaling audio. |
106 scoped_ptr<AudioRendererAlgorithmBase> algorithm_; | 115 scoped_ptr<AudioRendererAlgorithmBase> algorithm_; |
107 | 116 |
108 base::Lock lock_; | 117 base::Lock lock_; |
109 | 118 |
110 // Simple state tracking variable. | 119 // Simple state tracking variable. |
111 enum State { | 120 enum State { |
112 kUninitialized, | 121 kUninitialized, |
113 kPaused, | 122 kPaused, |
114 kSeeking, | 123 kSeeking, |
115 kPlaying, | 124 kPlaying, |
116 kStopped, | 125 kStopped, |
117 kError, | |
118 kUnderflow, | 126 kUnderflow, |
119 kRebuffering, | 127 kRebuffering, |
120 }; | 128 }; |
121 State state_; | 129 State state_; |
122 | 130 |
123 // Keep track of our outstanding read to |decoder_|. | 131 // Keep track of our outstanding read to |decoder_|. |
124 bool pending_read_; | 132 bool pending_read_; |
125 | 133 |
126 // Keeps track of whether we received and rendered the end of stream buffer. | 134 // Keeps track of whether we received and rendered the end of stream buffer. |
127 bool recieved_end_of_stream_; | 135 bool recieved_end_of_stream_; |
(...skipping 12 matching lines...) Expand all Loading... |
140 base::TimeDelta seek_timestamp_; | 148 base::TimeDelta seek_timestamp_; |
141 | 149 |
142 AudioDecoder::ReadCB read_cb_; | 150 AudioDecoder::ReadCB read_cb_; |
143 | 151 |
144 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); | 152 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); |
145 }; | 153 }; |
146 | 154 |
147 } // namespace media | 155 } // namespace media |
148 | 156 |
149 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 157 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
OLD | NEW |