| 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. |
| 11 // - The latency consists of two parts: | 11 // - The latency consists of two parts: |
| 12 // 1) Hardware latency, which includes Audio Unit latency, audio device | 12 // 1) Hardware latency, which includes Audio Unit latency, audio device |
| 13 // latency; | 13 // latency; |
| 14 // 2) The delay between the moment getting the callback and the scheduled time | 14 // 2) The delay between the moment getting the callback and the scheduled time |
| 15 // stamp that tells when the data is going to be played out. | 15 // stamp that tells when the data is going to be played out. |
| 16 // | 16 // |
| 17 #ifndef MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 17 #ifndef MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| 18 #define MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 18 #define MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| 19 | 19 |
| 20 #include <AudioUnit/AudioUnit.h> | 20 #include <AudioUnit/AudioUnit.h> |
| 21 #include <CoreAudio/CoreAudio.h> | 21 #include <CoreAudio/CoreAudio.h> |
| 22 #include <stddef.h> | 22 #include <stddef.h> |
| 23 #include <stdint.h> | 23 #include <stdint.h> |
| 24 | 24 |
| 25 #include <memory> | 25 #include <memory> |
| 26 #include <vector> |
| 26 | 27 |
| 27 #include "base/cancelable_callback.h" | 28 #include "base/cancelable_callback.h" |
| 28 #include "base/compiler_specific.h" | 29 #include "base/compiler_specific.h" |
| 29 #include "base/macros.h" | 30 #include "base/macros.h" |
| 30 #include "base/synchronization/lock.h" | 31 #include "base/synchronization/lock.h" |
| 31 #include "base/threading/thread_checker.h" | 32 #include "base/threading/thread_checker.h" |
| 32 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 33 #include "media/audio/audio_io.h" | 34 #include "media/audio/audio_io.h" |
| 34 #include "media/audio/audio_manager.h" | 35 #include "media/audio/audio_manager.h" |
| 35 #include "media/base/audio_parameters.h" | 36 #include "media/base/audio_parameters.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Returns the playout time for a given AudioTimeStamp. | 135 // Returns the playout time for a given AudioTimeStamp. |
| 135 base::TimeTicks GetPlayoutTime(const AudioTimeStamp* output_time_stamp); | 136 base::TimeTicks GetPlayoutTime(const AudioTimeStamp* output_time_stamp); |
| 136 | 137 |
| 137 // Updates playout timestamp, current lost frames, and total lost frames and | 138 // Updates playout timestamp, current lost frames, and total lost frames and |
| 138 // glitches. | 139 // glitches. |
| 139 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); | 140 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); |
| 140 | 141 |
| 141 // Called from the dtor and when the stream is reset. | 142 // Called from the dtor and when the stream is reset. |
| 142 void ReportAndResetStats(); | 143 void ReportAndResetStats(); |
| 143 | 144 |
| 145 // Converts |params_.channel_layout()| into CoreAudio format and sets up the |
| 146 // AUHAL with our layout information so it knows how to remap the channels. |
| 147 void SetAudioChannelLayout(); |
| 148 |
| 144 // Our creator, the audio manager needs to be notified when we close. | 149 // Our creator, the audio manager needs to be notified when we close. |
| 145 AudioManagerMac* const manager_; | 150 AudioManagerMac* const manager_; |
| 146 | 151 |
| 147 const AudioParameters params_; | 152 const AudioParameters params_; |
| 148 // For convenience - same as in params_. | 153 // For convenience - same as in params_. |
| 149 const int output_channels_; | 154 const int output_channels_; |
| 150 | 155 |
| 151 // Size of audio buffer requested at construction. The actual buffer size | 156 // Size of audio buffer requested at construction. The actual buffer size |
| 152 // is given by |actual_io_buffer_frame_size_| and it can differ from the | 157 // is given by |actual_io_buffer_frame_size_| and it can differ from the |
| 153 // requested size. | 158 // requested size. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // Used to make sure control functions (Start(), Stop() etc) are called on the | 227 // Used to make sure control functions (Start(), Stop() etc) are called on the |
| 223 // right thread. | 228 // right thread. |
| 224 base::ThreadChecker thread_checker_; | 229 base::ThreadChecker thread_checker_; |
| 225 | 230 |
| 226 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 231 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
| 227 }; | 232 }; |
| 228 | 233 |
| 229 } // namespace media | 234 } // namespace media |
| 230 | 235 |
| 231 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 236 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| OLD | NEW |