Chromium Code Reviews| 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 // 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 // otherwise. | 55 // otherwise. |
| 56 virtual bool OnInitialize(int bits_per_channel, | 56 virtual bool OnInitialize(int bits_per_channel, |
| 57 ChannelLayout channel_layout, | 57 ChannelLayout channel_layout, |
| 58 int sample_rate) = 0; | 58 int sample_rate) = 0; |
| 59 | 59 |
| 60 // Called by Stop(). Subclasses should perform any necessary cleanup during | 60 // Called by Stop(). Subclasses should perform any necessary cleanup during |
| 61 // this time, such as stopping any running threads. | 61 // this time, such as stopping any running threads. |
| 62 virtual void OnStop() = 0; | 62 virtual void OnStop() = 0; |
| 63 | 63 |
| 64 // Method called by FillBuffer() when it finds that it reached end of stream. | 64 // Method called by FillBuffer() when it finds that it reached end of stream. |
| 65 // FillBuffer() cannot immediately signal end of stream event because browser | 65 // FillBuffer() cannot immediately signal end of stream event because browser |
|
Ami GONE FROM CHROMIUM
2012/01/30 17:37:42
The second sentence of this para should be an expl
acolwell GONE FROM CHROMIUM
2012/01/30 22:01:17
This is from a rebase. I'll fix it in a separate C
| |
| 66 // may have buffered data. | 66 // may have buffered data. |
| 67 virtual void OnRenderEndOfStream() = 0; | 67 virtual void OnRenderEndOfStream() = 0; |
| 68 | 68 |
| 69 // Callback from the audio decoder delivering decoded audio samples. | 69 // Callback from the audio decoder delivering decoded audio samples. |
| 70 void DecodedAudioReady(scoped_refptr<Buffer> buffer); | 70 void DecodedAudioReady(scoped_refptr<Buffer> buffer); |
| 71 | 71 |
| 72 // Fills the given buffer with audio data by delegating to its |algorithm_|. | 72 // Fills the given buffer with audio data by delegating to its |algorithm_|. |
| 73 // FillBuffer() also takes care of updating the clock. Returns the number of | 73 // FillBuffer() also takes care of updating the clock. Returns the number of |
| 74 // bytes copied into |dest|, which may be less than or equal to |len|. | 74 // bytes copied into |dest|, which may be less than or equal to |len|. |
| 75 // | 75 // |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 91 // buffers become empty (i.e. when all the data written to the device has | 91 // buffers become empty (i.e. when all the data written to the device has |
| 92 // been played). | 92 // been played). |
| 93 // | 93 // |
| 94 // Safe to call on any thread. | 94 // Safe to call on any thread. |
| 95 uint32 FillBuffer(uint8* dest, | 95 uint32 FillBuffer(uint8* dest, |
| 96 uint32 len, | 96 uint32 len, |
| 97 const base::TimeDelta& playback_delay); | 97 const base::TimeDelta& playback_delay); |
| 98 | 98 |
| 99 // Called by OnRenderEndOfStream() or some callback scheduled by derived class | 99 // Called by OnRenderEndOfStream() or some callback scheduled by derived class |
| 100 // to signal end of stream. | 100 // to signal end of stream. |
| 101 void SignalEndOfStream(); | 101 void SignalEndOfStream(); |
|
Ami GONE FROM CHROMIUM
2012/01/30 17:37:42
I am unhappy about the names OnRenderEOS / SignalE
acolwell GONE FROM CHROMIUM
2012/01/30 22:01:17
This is from a rebase. I'll fix it in a separate C
| |
| 102 | 102 |
| 103 // Get/Set the playback rate of |algorithm_|. | 103 // Get/Set the playback rate of |algorithm_|. |
| 104 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 104 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
| 105 virtual float GetPlaybackRate(); | 105 virtual float GetPlaybackRate(); |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 friend class AudioRendererBaseTest; | 108 friend class AudioRendererBaseTest; |
| 109 | 109 |
| 110 // Helper method that schedules an asynchronous read from the decoder and | 110 // Helper method that schedules an asynchronous read from the decoder and |
| 111 // increments |pending_reads_|. | 111 // increments |pending_reads_|. |
| 112 // | 112 // |
| 113 // Safe to call from any thread. | 113 // Safe to call from any thread. |
| 114 void ScheduleRead_Locked(); | 114 void ScheduleRead_Locked(); |
| 115 | 115 |
| 116 // Returns true if the data in the buffer is all before | |
| 117 // |seek_timestamp_|. This can only return true while | |
| 118 // in the kSeeking state. | |
| 119 bool IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer); | |
| 120 | |
| 116 // Audio decoder. | 121 // Audio decoder. |
| 117 scoped_refptr<AudioDecoder> decoder_; | 122 scoped_refptr<AudioDecoder> decoder_; |
| 118 | 123 |
| 119 // Algorithm for scaling audio. | 124 // Algorithm for scaling audio. |
| 120 scoped_ptr<AudioRendererAlgorithmBase> algorithm_; | 125 scoped_ptr<AudioRendererAlgorithmBase> algorithm_; |
| 121 | 126 |
| 122 base::Lock lock_; | 127 base::Lock lock_; |
| 123 | 128 |
| 124 // Simple state tracking variable. | 129 // Simple state tracking variable. |
| 125 enum State { | 130 enum State { |
| 126 kUninitialized, | 131 kUninitialized, |
| 127 kPaused, | 132 kPaused, |
| 128 kSeeking, | 133 kSeeking, |
| 129 kPlaying, | 134 kPlaying, |
| 130 kStopped, | 135 kStopped, |
| 131 kError, | |
| 132 kUnderflow, | 136 kUnderflow, |
| 133 kRebuffering, | 137 kRebuffering, |
| 134 }; | 138 }; |
| 135 State state_; | 139 State state_; |
| 136 | 140 |
| 137 // Keep track of our outstanding read to |decoder_|. | 141 // Keep track of our outstanding read to |decoder_|. |
| 138 bool pending_read_; | 142 bool pending_read_; |
| 139 | 143 |
| 140 // Keeps track of whether we received and rendered the end of stream buffer. | 144 // Keeps track of whether we received and rendered the end of stream buffer. |
| 141 bool recieved_end_of_stream_; | 145 bool recieved_end_of_stream_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 154 base::TimeDelta seek_timestamp_; | 158 base::TimeDelta seek_timestamp_; |
| 155 | 159 |
| 156 AudioDecoder::ReadCB read_cb_; | 160 AudioDecoder::ReadCB read_cb_; |
| 157 | 161 |
| 158 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); | 162 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); |
| 159 }; | 163 }; |
| 160 | 164 |
| 161 } // namespace media | 165 } // namespace media |
| 162 | 166 |
| 163 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 167 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
| OLD | NEW |