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 12 matching lines...) Expand all Loading... |
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 "media/audio/audio_io.h" | 32 #include "media/audio/audio_io.h" |
33 #include "media/audio/audio_manager.h" | |
34 #include "media/base/audio_parameters.h" | 33 #include "media/base/audio_parameters.h" |
35 | 34 |
36 namespace media { | 35 namespace media { |
37 | 36 |
38 class AudioManagerMac; | 37 class AudioManagerMac; |
39 class AudioPullFifo; | 38 class AudioPullFifo; |
40 | 39 |
41 // Implementation of AudioOuputStream for Mac OS X using the | 40 // Implementation of AudioOuputStream for Mac OS X using the |
42 // AUHAL Audio Unit present in OS 10.4 and later. | 41 // AUHAL Audio Unit present in OS 10.4 and later. |
43 // It is useful for low-latency output. | 42 // It is useful for low-latency output. |
(...skipping 23 matching lines...) Expand all Loading... |
67 // between the browser and render process in AudioSyncReader. | 66 // between the browser and render process in AudioSyncReader. |
68 // We need to fix this. | 67 // We need to fix this. |
69 | 68 |
70 class AUHALStream : public AudioOutputStream { | 69 class AUHALStream : public AudioOutputStream { |
71 public: | 70 public: |
72 // |manager| creates this object. | 71 // |manager| creates this object. |
73 // |device| is the CoreAudio device to use for the stream. | 72 // |device| is the CoreAudio device to use for the stream. |
74 // It will often be the default output device. | 73 // It will often be the default output device. |
75 AUHALStream(AudioManagerMac* manager, | 74 AUHALStream(AudioManagerMac* manager, |
76 const AudioParameters& params, | 75 const AudioParameters& params, |
77 AudioDeviceID device, | 76 AudioDeviceID device); |
78 const AudioManager::LogCallback& log_callback); | |
79 // The dtor is typically called by the AudioManager only and it is usually | 77 // The dtor is typically called by the AudioManager only and it is usually |
80 // triggered by calling AudioOutputStream::Close(). | 78 // triggered by calling AudioOutputStream::Close(). |
81 ~AUHALStream() override; | 79 ~AUHALStream() override; |
82 | 80 |
83 // Implementation of AudioOutputStream. | 81 // Implementation of AudioOutputStream. |
84 bool Open() override; | 82 bool Open() override; |
85 void Close() override; | 83 void Close() override; |
86 void Start(AudioSourceCallback* callback) override; | 84 void Start(AudioSourceCallback* callback) override; |
87 void Stop() override; | 85 void Stop() override; |
88 void SetVolume(double volume) override; | 86 void SetVolume(double volume) override; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // NOTE: Float64 and UInt32 types are used for native API compatibility. | 207 // NOTE: Float64 and UInt32 types are used for native API compatibility. |
210 Float64 last_sample_time_; | 208 Float64 last_sample_time_; |
211 UInt32 last_number_of_frames_; | 209 UInt32 last_number_of_frames_; |
212 UInt32 total_lost_frames_; | 210 UInt32 total_lost_frames_; |
213 UInt32 largest_glitch_frames_; | 211 UInt32 largest_glitch_frames_; |
214 int glitches_detected_; | 212 int glitches_detected_; |
215 | 213 |
216 // Used to defer Start() to workaround http://crbug.com/160920. | 214 // Used to defer Start() to workaround http://crbug.com/160920. |
217 base::CancelableClosure deferred_start_cb_; | 215 base::CancelableClosure deferred_start_cb_; |
218 | 216 |
219 // Callback to send statistics info. | |
220 AudioManager::LogCallback log_callback_; | |
221 | |
222 // Used to make sure control functions (Start(), Stop() etc) are called on the | 217 // Used to make sure control functions (Start(), Stop() etc) are called on the |
223 // right thread. | 218 // right thread. |
224 base::ThreadChecker thread_checker_; | 219 base::ThreadChecker thread_checker_; |
225 | 220 |
226 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 221 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
227 }; | 222 }; |
228 | 223 |
229 } // namespace media | 224 } // namespace media |
230 | 225 |
231 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 226 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
OLD | NEW |