| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 25 matching lines...) Expand all Loading... |
| 36 virtual bool Initialize(AudioDecoder* decoder); | 36 virtual bool Initialize(AudioDecoder* decoder); |
| 37 | 37 |
| 38 // AssignableBuffer<AudioRendererBase, BufferInterface> implementation. | 38 // AssignableBuffer<AudioRendererBase, BufferInterface> implementation. |
| 39 virtual void OnAssignment(Buffer* buffer_in); | 39 virtual void OnAssignment(Buffer* buffer_in); |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 // The default maximum size of the queue. | 42 // The default maximum size of the queue. |
| 43 static const size_t kDefaultMaxQueueSize; | 43 static const size_t kDefaultMaxQueueSize; |
| 44 | 44 |
| 45 // Only allow a factory to create this class. | 45 // Only allow a factory to create this class. |
| 46 AudioRendererBase(size_t max_queue_size); | 46 explicit AudioRendererBase(size_t max_queue_size); |
| 47 virtual ~AudioRendererBase(); | 47 virtual ~AudioRendererBase(); |
| 48 | 48 |
| 49 // Called by Initialize(). |media_format| is the format of the AudioDecoder. | 49 // Called by Initialize(). |media_format| is the format of the AudioDecoder. |
| 50 // Subclasses should return true if they were able to initialize, false | 50 // Subclasses should return true if they were able to initialize, false |
| 51 // otherwise. | 51 // otherwise. |
| 52 virtual bool OnInitialize(const MediaFormat* media_format) = 0; | 52 virtual bool OnInitialize(const MediaFormat& media_format) = 0; |
| 53 | 53 |
| 54 // Called by Stop(). Subclasses should perform any necessary cleanup during | 54 // Called by Stop(). Subclasses should perform any necessary cleanup during |
| 55 // this time, such as stopping any running threads. | 55 // this time, such as stopping any running threads. |
| 56 virtual void OnStop() = 0; | 56 virtual void OnStop() = 0; |
| 57 | 57 |
| 58 // Fills the given buffer with audio data by dequeuing buffers and copying the | 58 // Fills the given buffer with audio data by dequeuing buffers and copying the |
| 59 // data into the |dest|. FillBuffer also takes care of updating the clock. | 59 // data into the |dest|. FillBuffer also takes care of updating the clock. |
| 60 // Returns the number of bytes copied into |dest|, which may be less than | 60 // Returns the number of bytes copied into |dest|, which may be less than |
| 61 // equal to |len|. | 61 // equal to |len|. |
| 62 // | 62 // |
| 63 // If this method is returns less bytes than |len| (including zero), it could | 63 // If this method is returns less bytes than |len| (including zero), it could |
| 64 // be a sign that the pipeline is stalled or unable to stream the data fast | 64 // be a sign that the pipeline is stalled or unable to stream the data fast |
| 65 // enough. In such scenarios, the callee should zero out unused portions | 65 // enough. In such scenarios, the callee should zero out unused portions |
| 66 // of their buffer to playback silence. | 66 // of their buffer to playback silence. |
| 67 // | 67 // |
| 68 // Safe to call on any thread. | 68 // Safe to call on any thread. |
| 69 size_t FillBuffer(uint8* dest, size_t len); | 69 size_t FillBuffer(uint8* dest, size_t len); |
| 70 | 70 |
| 71 // Helper to parse a media format and return whether we were successful | 71 // Helper to parse a media format and return whether we were successful |
| 72 // retrieving all the information we care about. | 72 // retrieving all the information we care about. |
| 73 static bool ParseMediaFormat(const MediaFormat* media_format, | 73 static bool ParseMediaFormat(const MediaFormat& media_format, |
| 74 int* channels_out, int* sample_rate_out, | 74 int* channels_out, int* sample_rate_out, |
| 75 int* sample_bits_out); | 75 int* sample_bits_out); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Audio decoder. | 78 // Audio decoder. |
| 79 AudioDecoder* decoder_; | 79 AudioDecoder* decoder_; |
| 80 | 80 |
| 81 // Maximum queue size, configuration parameter passed in during construction. | 81 // Maximum queue size, configuration parameter passed in during construction. |
| 82 size_t max_queue_size_; | 82 size_t max_queue_size_; |
| 83 | 83 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 // | 100 // |
| 101 // Safe to call on any thread. | 101 // Safe to call on any thread. |
| 102 void ScheduleRead(); | 102 void ScheduleRead(); |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); | 104 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace media | 107 } // namespace media |
| 108 | 108 |
| 109 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 109 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
| OLD | NEW |