| 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> |
| 26 |
| 25 #include "base/cancelable_callback.h" | 27 #include "base/cancelable_callback.h" |
| 26 #include "base/compiler_specific.h" | 28 #include "base/compiler_specific.h" |
| 27 #include "base/macros.h" | 29 #include "base/macros.h" |
| 28 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" |
| 29 #include "base/threading/thread_checker.h" | 31 #include "base/threading/thread_checker.h" |
| 30 #include "media/audio/audio_io.h" | 32 #include "media/audio/audio_io.h" |
| 31 #include "media/base/audio_parameters.h" | 33 #include "media/base/audio_parameters.h" |
| 32 | 34 |
| 33 namespace media { | 35 namespace media { |
| 34 | 36 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Volume level from 0 to 1. | 173 // Volume level from 0 to 1. |
| 172 float volume_; | 174 float volume_; |
| 173 | 175 |
| 174 // Fixed playout hardware latency in frames. | 176 // Fixed playout hardware latency in frames. |
| 175 double hardware_latency_frames_; | 177 double hardware_latency_frames_; |
| 176 | 178 |
| 177 // This flag will be set to false while we're actively receiving callbacks. | 179 // This flag will be set to false while we're actively receiving callbacks. |
| 178 bool stopped_; | 180 bool stopped_; |
| 179 | 181 |
| 180 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 182 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| 181 scoped_ptr<AudioBus> output_bus_; | 183 std::unique_ptr<AudioBus> output_bus_; |
| 182 | 184 |
| 183 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame | 185 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame |
| 184 // sizes. | 186 // sizes. |
| 185 scoped_ptr<AudioPullFifo> audio_fifo_; | 187 std::unique_ptr<AudioPullFifo> audio_fifo_; |
| 186 | 188 |
| 187 // Current buffer delay. Set by Render(). | 189 // Current buffer delay. Set by Render(). |
| 188 uint32_t current_hardware_pending_bytes_; | 190 uint32_t current_hardware_pending_bytes_; |
| 189 | 191 |
| 190 // Lost frames not yet reported to the provider. Increased in | 192 // Lost frames not yet reported to the provider. Increased in |
| 191 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to | 193 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to |
| 192 // the provider and reset in ProvideInput(). | 194 // the provider and reset in ProvideInput(). |
| 193 uint32_t current_lost_frames_; | 195 uint32_t current_lost_frames_; |
| 194 | 196 |
| 195 // Stores the timestamp of the previous audio buffer requested by the OS. | 197 // Stores the timestamp of the previous audio buffer requested by the OS. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 212 // Used to make sure control functions (Start(), Stop() etc) are called on the | 214 // Used to make sure control functions (Start(), Stop() etc) are called on the |
| 213 // right thread. | 215 // right thread. |
| 214 base::ThreadChecker thread_checker_; | 216 base::ThreadChecker thread_checker_; |
| 215 | 217 |
| 216 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 218 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
| 217 }; | 219 }; |
| 218 | 220 |
| 219 } // namespace media | 221 } // namespace media |
| 220 | 222 |
| 221 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 223 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| OLD | NEW |