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 11 matching lines...) Expand all Loading... |
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 | 26 |
27 #include "base/cancelable_callback.h" | 27 #include "base/cancelable_callback.h" |
28 #include "base/compiler_specific.h" | 28 #include "base/compiler_specific.h" |
29 #include "base/macros.h" | 29 #include "base/macros.h" |
30 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" |
31 #include "base/threading/thread_checker.h" | 31 #include "base/threading/thread_checker.h" |
| 32 #include "base/time/time.h" |
32 #include "media/audio/audio_io.h" | 33 #include "media/audio/audio_io.h" |
33 #include "media/audio/audio_manager.h" | 34 #include "media/audio/audio_manager.h" |
34 #include "media/base/audio_parameters.h" | 35 #include "media/base/audio_parameters.h" |
35 | 36 |
36 namespace media { | 37 namespace media { |
37 | 38 |
38 class AudioManagerMac; | 39 class AudioManagerMac; |
39 class AudioPullFifo; | 40 class AudioPullFifo; |
40 | 41 |
41 // Implementation of AudioOuputStream for Mac OS X using the | 42 // Implementation of AudioOuputStream for Mac OS X using the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Uninitializes audio_unit_ if needed. | 125 // Uninitializes audio_unit_ if needed. |
125 void CloseAudioUnit(); | 126 void CloseAudioUnit(); |
126 | 127 |
127 // Creates the input and output busses. | 128 // Creates the input and output busses. |
128 void CreateIOBusses(); | 129 void CreateIOBusses(); |
129 | 130 |
130 // Gets the fixed playout device hardware latency and stores it. Returns 0 | 131 // Gets the fixed playout device hardware latency and stores it. Returns 0 |
131 // if not available. | 132 // if not available. |
132 double GetHardwareLatency(); | 133 double GetHardwareLatency(); |
133 | 134 |
134 // Gets the current playout latency value. | 135 // Gets the current target playout time. |
135 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp); | 136 base::TimeTicks GetTargetPlayoutTime(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 |
144 // Our creator, the audio manager needs to be notified when we close. | 145 // Our creator, the audio manager needs to be notified when we close. |
145 AudioManagerMac* const manager_; | 146 AudioManagerMac* const manager_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // This flag will be set to false while we're actively receiving callbacks. | 185 // This flag will be set to false while we're actively receiving callbacks. |
185 bool stopped_; | 186 bool stopped_; |
186 | 187 |
187 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 188 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
188 std::unique_ptr<AudioBus> output_bus_; | 189 std::unique_ptr<AudioBus> output_bus_; |
189 | 190 |
190 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame | 191 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame |
191 // sizes. | 192 // sizes. |
192 std::unique_ptr<AudioPullFifo> audio_fifo_; | 193 std::unique_ptr<AudioPullFifo> audio_fifo_; |
193 | 194 |
194 // Current buffer delay. Set by Render(). | 195 // Current target playout time. Set by Render(). |
195 uint32_t current_hardware_pending_bytes_; | 196 base::TimeTicks current_target_playout_time_; |
196 | 197 |
197 // Lost frames not yet reported to the provider. Increased in | 198 // Lost frames not yet reported to the provider. Increased in |
198 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to | 199 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to |
199 // the provider and reset in ProvideInput(). | 200 // the provider and reset in ProvideInput(). |
200 uint32_t current_lost_frames_; | 201 uint32_t current_lost_frames_; |
201 | 202 |
202 // Stores the timestamp of the previous audio buffer requested by the OS. | 203 // Stores the timestamp of the previous audio buffer requested by the OS. |
203 // We use this in combination with |last_number_of_frames_| to detect when | 204 // We use this in combination with |last_number_of_frames_| to detect when |
204 // the OS has decided to skip rendering frames (i.e. a glitch). | 205 // the OS has decided to skip rendering frames (i.e. a glitch). |
205 // This can happen in case of high CPU load or excessive blocking on the | 206 // This can happen in case of high CPU load or excessive blocking on the |
(...skipping 16 matching lines...) Expand all Loading... |
222 // Used to make sure control functions (Start(), Stop() etc) are called on the | 223 // Used to make sure control functions (Start(), Stop() etc) are called on the |
223 // right thread. | 224 // right thread. |
224 base::ThreadChecker thread_checker_; | 225 base::ThreadChecker thread_checker_; |
225 | 226 |
226 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 227 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
227 }; | 228 }; |
228 | 229 |
229 } // namespace media | 230 } // namespace media |
230 | 231 |
231 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 232 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
OLD | NEW |