Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: media/audio/mac/audio_auhal_mac.h

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Pass target playout time to AudioSourceCallback::OnMoreData. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp);
136
137 // Updates playout timestamp, current lost frames, and total lost frames and 135 // Updates playout timestamp, current lost frames, and total lost frames and
138 // glitches. 136 // glitches.
139 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); 137 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp);
140 138
141 // Called from the dtor and when the stream is reset. 139 // Called from the dtor and when the stream is reset.
142 void ReportAndResetStats(); 140 void ReportAndResetStats();
143 141
144 // Our creator, the audio manager needs to be notified when we close. 142 // Our creator, the audio manager needs to be notified when we close.
145 AudioManagerMac* const manager_; 143 AudioManagerMac* const manager_;
146 144
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // This flag will be set to false while we're actively receiving callbacks. 182 // This flag will be set to false while we're actively receiving callbacks.
185 bool stopped_; 183 bool stopped_;
186 184
187 // Container for retrieving data from AudioSourceCallback::OnMoreData(). 185 // Container for retrieving data from AudioSourceCallback::OnMoreData().
188 std::unique_ptr<AudioBus> output_bus_; 186 std::unique_ptr<AudioBus> output_bus_;
189 187
190 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame 188 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame
191 // sizes. 189 // sizes.
192 std::unique_ptr<AudioPullFifo> audio_fifo_; 190 std::unique_ptr<AudioPullFifo> audio_fifo_;
193 191
194 // Current buffer delay. Set by Render(). 192 // Current target playout time. Set by Render().
195 uint32_t current_hardware_pending_bytes_; 193 base::TimeTicks current_target_playout_time_;
196 194
197 // Lost frames not yet reported to the provider. Increased in 195 // Lost frames not yet reported to the provider. Increased in
198 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to 196 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to
199 // the provider and reset in ProvideInput(). 197 // the provider and reset in ProvideInput().
200 uint32_t current_lost_frames_; 198 uint32_t current_lost_frames_;
201 199
202 // Stores the timestamp of the previous audio buffer requested by the OS. 200 // 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 201 // 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). 202 // 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 203 // This can happen in case of high CPU load or excessive blocking on the
(...skipping 16 matching lines...) Expand all
222 // Used to make sure control functions (Start(), Stop() etc) are called on the 220 // Used to make sure control functions (Start(), Stop() etc) are called on the
223 // right thread. 221 // right thread.
224 base::ThreadChecker thread_checker_; 222 base::ThreadChecker thread_checker_;
225 223
226 DISALLOW_COPY_AND_ASSIGN(AUHALStream); 224 DISALLOW_COPY_AND_ASSIGN(AUHALStream);
227 }; 225 };
228 226
229 } // namespace media 227 } // namespace media
230 228
231 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ 229 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698