| 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 // Implementation notes: | 5 // Implementation notes: |
| 6 // | 6 // |
| 7 // - It is recommended to first acquire the native sample rate of the default | 7 // - It is recommended to first acquire the native sample rate of the default |
| 8 // output device and then use the same rate when creating this object. | 8 // output device and then use the same rate when creating this object. |
| 9 // Use AudioManagerMac::HardwareSampleRate() to retrieve the sample rate. | 9 // Use AudioManagerMac::HardwareSampleRate() to retrieve the sample rate. |
| 10 // - Calling Close() also leads to self destruction. | 10 // - Calling Close() also leads to self destruction. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Implementation of AudioOutputStream. | 79 // Implementation of AudioOutputStream. |
| 80 bool Open() override; | 80 bool Open() override; |
| 81 void Close() override; | 81 void Close() override; |
| 82 void Start(AudioSourceCallback* callback) override; | 82 void Start(AudioSourceCallback* callback) override; |
| 83 void Stop() override; | 83 void Stop() override; |
| 84 void SetVolume(double volume) override; | 84 void SetVolume(double volume) override; |
| 85 void GetVolume(double* volume) override; | 85 void GetVolume(double* volume) override; |
| 86 | 86 |
| 87 AudioDeviceID device_id() const { return device_; } | 87 AudioDeviceID device_id() const { return device_; } |
| 88 size_t requested_buffer_size() const { return number_of_frames_; } | 88 size_t requested_buffer_size() const { return number_of_frames_; } |
| 89 size_t actual_buffer_size() const { return actual_io_buffer_frame_size_; } |
| 90 AudioUnit audio_unit() const { return audio_unit_; } |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 // AUHAL callback. | 93 // AUHAL callback. |
| 92 static OSStatus InputProc(void* user_data, | 94 static OSStatus InputProc(void* user_data, |
| 93 AudioUnitRenderActionFlags* flags, | 95 AudioUnitRenderActionFlags* flags, |
| 94 const AudioTimeStamp* time_stamp, | 96 const AudioTimeStamp* time_stamp, |
| 95 UInt32 bus_number, | 97 UInt32 bus_number, |
| 96 UInt32 number_of_frames, | 98 UInt32 number_of_frames, |
| 97 AudioBufferList* io_data); | 99 AudioBufferList* io_data); |
| 98 | 100 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Called from the dtor and when the stream is reset. | 138 // Called from the dtor and when the stream is reset. |
| 137 void ReportAndResetStats(); | 139 void ReportAndResetStats(); |
| 138 | 140 |
| 139 // Our creator, the audio manager needs to be notified when we close. | 141 // Our creator, the audio manager needs to be notified when we close. |
| 140 AudioManagerMac* const manager_; | 142 AudioManagerMac* const manager_; |
| 141 | 143 |
| 142 const AudioParameters params_; | 144 const AudioParameters params_; |
| 143 // For convenience - same as in params_. | 145 // For convenience - same as in params_. |
| 144 const int output_channels_; | 146 const int output_channels_; |
| 145 | 147 |
| 146 // Buffer-size. | 148 // Size of audio buffer requested at construction. The actual buffer size |
| 149 // is given by |actual_io_buffer_frame_size_| and it can differ from the |
| 150 // requested size. |
| 147 const size_t number_of_frames_; | 151 const size_t number_of_frames_; |
| 148 | 152 |
| 153 // Size of I/O buffers measured in number of audio frames. Default value is |
| 154 // 512 but we always try to set it to a vaule as close as possible to |
| 155 // |number_of_frames_|. It might not be possible to match the requested size, |
| 156 // especially not if the utilized device is used by other streams as well. |
| 157 // This value will be the same as |number_of_frames_requested_| but they are |
| 158 // used for different purpuses and updated at different times. |
| 159 size_t actual_io_buffer_frame_size_; |
| 160 |
| 149 // Stores the number of frames that we actually get callbacks for. | 161 // Stores the number of frames that we actually get callbacks for. |
| 150 // This may be different from what we ask for, so we use this for stats in | 162 // This may be different from what we ask for, so we use this for stats in |
| 151 // order to understand how often this happens and what are the typical values. | 163 // order to understand how often this happens and what are the typical values. |
| 152 size_t number_of_frames_requested_; | 164 size_t number_of_frames_requested_; |
| 153 | 165 |
| 154 // Pointer to the object that will provide the audio samples. | 166 // Pointer to the object that will provide the audio samples. |
| 155 AudioSourceCallback* source_; | 167 AudioSourceCallback* source_; |
| 156 | 168 |
| 157 // Protects |source_|. Necessary since Render() calls seem to be in flight | 169 // Protects |source_|. Necessary since Render() calls seem to be in flight |
| 158 // when |audio_unit_| is supposedly stopped. See http://crbug.com/178765. | 170 // when |audio_unit_| is supposedly stopped. See http://crbug.com/178765. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Used to make sure control functions (Start(), Stop() etc) are called on the | 224 // Used to make sure control functions (Start(), Stop() etc) are called on the |
| 213 // right thread. | 225 // right thread. |
| 214 base::ThreadChecker thread_checker_; | 226 base::ThreadChecker thread_checker_; |
| 215 | 227 |
| 216 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 228 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 } // namespace media | 231 } // namespace media |
| 220 | 232 |
| 221 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 233 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| OLD | NEW |