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

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

Issue 1911913002: Convert //media/audio from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 of AudioInputStream for Mac OS X using the special AUHAL 5 // Implementation of AudioInputStream for Mac OS X using the special AUHAL
6 // input Audio Unit present in OS 10.4 and later. 6 // input Audio Unit present in OS 10.4 and later.
7 // The AUHAL input Audio Unit is for low-latency audio I/O. 7 // The AUHAL input Audio Unit is for low-latency audio I/O.
8 // 8 //
9 // Overview of operation: 9 // Overview of operation:
10 // 10 //
(...skipping 20 matching lines...) Expand all
31 // 1) Hardware latency, which includes Audio Unit latency, audio device 31 // 1) Hardware latency, which includes Audio Unit latency, audio device
32 // latency; 32 // latency;
33 // 2) The delay between the actual recording instant and the time when the 33 // 2) The delay between the actual recording instant and the time when the
34 // data packet is provided as a callback. 34 // data packet is provided as a callback.
35 // 35 //
36 #ifndef MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ 36 #ifndef MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_
37 #define MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ 37 #define MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_
38 38
39 #include <AudioUnit/AudioUnit.h> 39 #include <AudioUnit/AudioUnit.h>
40 #include <CoreAudio/CoreAudio.h> 40 #include <CoreAudio/CoreAudio.h>
41
41 #include <map> 42 #include <map>
43 #include <memory>
42 #include <vector> 44 #include <vector>
43 45
44 #include "base/atomicops.h" 46 #include "base/atomicops.h"
45 #include "base/cancelable_callback.h" 47 #include "base/cancelable_callback.h"
46 #include "base/macros.h" 48 #include "base/macros.h"
47 #include "base/memory/scoped_ptr.h"
48 #include "base/memory/weak_ptr.h" 49 #include "base/memory/weak_ptr.h"
49 #include "base/threading/thread_checker.h" 50 #include "base/threading/thread_checker.h"
50 #include "base/time/time.h" 51 #include "base/time/time.h"
51 #include "base/timer/timer.h" 52 #include "base/timer/timer.h"
52 #include "media/audio/agc_audio_stream.h" 53 #include "media/audio/agc_audio_stream.h"
53 #include "media/audio/audio_io.h" 54 #include "media/audio/audio_io.h"
54 #include "media/base/audio_block_fifo.h" 55 #include "media/base/audio_block_fifo.h"
55 #include "media/base/audio_parameters.h" 56 #include "media/base/audio_parameters.h"
56 57
57 namespace media { 58 namespace media {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 AudioUnit audio_unit_; 223 AudioUnit audio_unit_;
223 224
224 // The UID refers to the current input audio device. 225 // The UID refers to the current input audio device.
225 const AudioDeviceID input_device_id_; 226 const AudioDeviceID input_device_id_;
226 227
227 // Provides a mechanism for encapsulating one or more buffers of audio data. 228 // Provides a mechanism for encapsulating one or more buffers of audio data.
228 AudioBufferList audio_buffer_list_; 229 AudioBufferList audio_buffer_list_;
229 230
230 // Temporary storage for recorded data. The InputProc() renders into this 231 // Temporary storage for recorded data. The InputProc() renders into this
231 // array as soon as a frame of the desired buffer size has been recorded. 232 // array as soon as a frame of the desired buffer size has been recorded.
232 scoped_ptr<uint8_t[]> audio_data_buffer_; 233 std::unique_ptr<uint8_t[]> audio_data_buffer_;
233 234
234 // Fixed capture hardware latency in frames. 235 // Fixed capture hardware latency in frames.
235 double hardware_latency_frames_; 236 double hardware_latency_frames_;
236 237
237 // The number of channels in each frame of audio data, which is used 238 // The number of channels in each frame of audio data, which is used
238 // when querying the volume of each channel. 239 // when querying the volume of each channel.
239 int number_of_channels_in_frame_; 240 int number_of_channels_in_frame_;
240 241
241 // FIFO used to accumulates recorded data. 242 // FIFO used to accumulates recorded data.
242 media::AudioBlockFifo fifo_; 243 media::AudioBlockFifo fifo_;
243 244
244 // Used to defer Start() to workaround http://crbug.com/160920. 245 // Used to defer Start() to workaround http://crbug.com/160920.
245 base::CancelableClosure deferred_start_cb_; 246 base::CancelableClosure deferred_start_cb_;
246 247
247 // Contains time of last successful call to AudioUnitRender(). 248 // Contains time of last successful call to AudioUnitRender().
248 // Initialized first time in Start() and then updated for each valid 249 // Initialized first time in Start() and then updated for each valid
249 // audio buffer. Used to detect long error sequences and to take actions 250 // audio buffer. Used to detect long error sequences and to take actions
250 // if length of error sequence is above a certain limit. 251 // if length of error sequence is above a certain limit.
251 base::TimeTicks last_success_time_; 252 base::TimeTicks last_success_time_;
252 253
253 // Is set to true on the internal AUHAL IO thread in the first input callback 254 // Is set to true on the internal AUHAL IO thread in the first input callback
254 // after Start() has bee called. 255 // after Start() has bee called.
255 base::subtle::Atomic32 input_callback_is_active_; 256 base::subtle::Atomic32 input_callback_is_active_;
256 257
257 // Timer which triggers CheckInputStartupSuccess() to verify that input 258 // Timer which triggers CheckInputStartupSuccess() to verify that input
258 // callbacks have started as intended after a successful call to Start(). 259 // callbacks have started as intended after a successful call to Start().
259 // This timer lives on the main browser thread. 260 // This timer lives on the main browser thread.
260 scoped_ptr<base::OneShotTimer> input_callback_timer_; 261 std::unique_ptr<base::OneShotTimer> input_callback_timer_;
261 262
262 // Set to true if the Start() call was delayed. 263 // Set to true if the Start() call was delayed.
263 // See AudioManagerMac::ShouldDeferStreamStart() for details. 264 // See AudioManagerMac::ShouldDeferStreamStart() for details.
264 bool start_was_deferred_; 265 bool start_was_deferred_;
265 266
266 // Set to true if the audio unit's IO buffer was changed when Open() was 267 // Set to true if the audio unit's IO buffer was changed when Open() was
267 // called. 268 // called.
268 bool buffer_size_was_changed_; 269 bool buffer_size_was_changed_;
269 270
270 // Set to true once when AudioUnitRender() succeeds for the first time. 271 // Set to true once when AudioUnitRender() succeeds for the first time.
(...skipping 23 matching lines...) Expand all
294 // in the dtor (when no longer receiving callbacks). 295 // in the dtor (when no longer receiving callbacks).
295 // NOTE: Float64 and UInt32 types are used for native API compatibility. 296 // NOTE: Float64 and UInt32 types are used for native API compatibility.
296 Float64 last_sample_time_; 297 Float64 last_sample_time_;
297 UInt32 last_number_of_frames_; 298 UInt32 last_number_of_frames_;
298 UInt32 total_lost_frames_; 299 UInt32 total_lost_frames_;
299 UInt32 largest_glitch_frames_; 300 UInt32 largest_glitch_frames_;
300 int glitches_detected_; 301 int glitches_detected_;
301 302
302 // Timer that provides periodic callbacks used to monitor if the input stream 303 // Timer that provides periodic callbacks used to monitor if the input stream
303 // is alive or not. 304 // is alive or not.
304 scoped_ptr<base::RepeatingTimer> check_alive_timer_; 305 std::unique_ptr<base::RepeatingTimer> check_alive_timer_;
305 306
306 // Time tick set once in each input data callback. The time is measured on 307 // Time tick set once in each input data callback. The time is measured on
307 // the real-time priority I/O thread but this member is modified and read 308 // the real-time priority I/O thread but this member is modified and read
308 // on the main thread only. 309 // on the main thread only.
309 base::TimeTicks last_callback_time_; 310 base::TimeTicks last_callback_time_;
310 311
311 // Counts number of times we get a signal of that a restart seems required. 312 // Counts number of times we get a signal of that a restart seems required.
312 // If it is above a threshold (kNumberOfIndicationsToTriggerRestart), the 313 // If it is above a threshold (kNumberOfIndicationsToTriggerRestart), the
313 // current audio stream is closed and a new (using same audio parameters) is 314 // current audio stream is closed and a new (using same audio parameters) is
314 // started. 315 // started.
(...skipping 12 matching lines...) Expand all
327 // this object is destroyed. 328 // this object is destroyed.
328 // Note that, all member variables should appear before the WeakPtrFactory. 329 // Note that, all member variables should appear before the WeakPtrFactory.
329 base::WeakPtrFactory<AUAudioInputStream> weak_factory_; 330 base::WeakPtrFactory<AUAudioInputStream> weak_factory_;
330 331
331 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); 332 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
332 }; 333 };
333 334
334 } // namespace media 335 } // namespace media
335 336
336 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ 337 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_input_mac.h ('k') | media/audio/mac/audio_low_latency_input_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698