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