OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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: | |
6 // | |
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. | |
9 // Use AUAudioOutputStream::HardwareSampleRate() to retrieve the sample rate. | |
10 // - Calling Close() also leads to self destruction. | |
11 // - The latency consists of two parts: | |
12 // 1, Hardware latency, which includes Audio Unit latency, audio device | |
13 // latency and audio stream latency; | |
14 // 2, The delay between now and the scheduled time stamp that tells when the | |
15 // data we are providing is going to reach the hardware. | |
16 // | |
5 #ifndef MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ | 17 #ifndef MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ |
6 #define MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ | 18 #define MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ |
7 | 19 |
8 #include <AudioUnit/AudioUnit.h> | 20 #include <AudioUnit/AudioUnit.h> |
9 | 21 |
22 #include "base/memory/scoped_ptr.h" | |
10 #include "media/audio/audio_io.h" | 23 #include "media/audio/audio_io.h" |
11 #include "media/audio/audio_parameters.h" | 24 #include "media/audio/audio_parameters.h" |
12 | 25 |
13 class AudioManagerMac; | 26 class AudioManagerMac; |
14 | 27 |
15 // Implementation of AudioOuputStream for Mac OS X using the | 28 // Implementation of AudioOuputStream for Mac OS X using the |
16 // default output Audio Unit present in OS 10.4 and later. | 29 // default output Audio Unit present in OS 10.4 and later. |
17 // The default output Audio Unit is for low-latency audio I/O. | 30 // The default output Audio Unit is for low-latency audio I/O. |
18 class AUAudioOutputStream : public AudioOutputStream { | 31 class AUAudioOutputStream : public AudioOutputStream { |
19 public: | 32 public: |
(...skipping 17 matching lines...) Expand all Loading... | |
37 | 50 |
38 private: | 51 private: |
39 // DefaultOutputUnit callback. | 52 // DefaultOutputUnit callback. |
40 static OSStatus InputProc(void* user_data, | 53 static OSStatus InputProc(void* user_data, |
41 AudioUnitRenderActionFlags* flags, | 54 AudioUnitRenderActionFlags* flags, |
42 const AudioTimeStamp* time_stamp, | 55 const AudioTimeStamp* time_stamp, |
43 UInt32 bus_number, | 56 UInt32 bus_number, |
44 UInt32 number_of_frames, | 57 UInt32 number_of_frames, |
45 AudioBufferList* io_data); | 58 AudioBufferList* io_data); |
46 | 59 |
47 OSStatus Render(UInt32 number_of_frames, AudioBufferList* io_data); | 60 OSStatus Render(UInt32 number_of_frames, AudioBufferList* io_data, |
61 const AudioTimeStamp* output_time_stamp); | |
48 | 62 |
49 // Sets up the stream format for the default output Audio Unit. | 63 // Sets up the stream format for the default output Audio Unit. |
50 bool Configure(); | 64 bool Configure(); |
51 | 65 |
66 // Gets the fixed playout device hardware latency and stores it. | |
67 double GetHardwareLatency(); | |
scherkus (not reviewing)
2011/10/19 18:23:57
ditto on returning zero
no longer working on chromium
2011/10/20 11:25:51
Done.
| |
68 | |
69 // Gets the current playout latency value. | |
70 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp); | |
71 | |
52 // Our creator, the audio manager needs to be notified when we close. | 72 // Our creator, the audio manager needs to be notified when we close. |
53 AudioManagerMac* manager_; | 73 AudioManagerMac* manager_; |
54 | 74 |
55 size_t number_of_frames_; | 75 size_t number_of_frames_; |
56 | 76 |
57 // Pointer to the object that will provide the audio samples. | 77 // Pointer to the object that will provide the audio samples. |
58 AudioSourceCallback* source_; | 78 AudioSourceCallback* source_; |
59 | 79 |
60 // Structure that holds the stream format details such as bitrate. | 80 // Structure that holds the stream format details such as bitrate. |
61 AudioStreamBasicDescription format_; | 81 AudioStreamBasicDescription format_; |
62 | 82 |
63 // The default output Audio Unit which talks to the audio hardware. | 83 // The default output Audio Unit which talks to the audio hardware. |
64 AudioUnit output_unit_; | 84 AudioUnit output_unit_; |
65 | 85 |
86 // The UID refers to the current output audio device. | |
87 AudioDeviceID output_device_id_; | |
88 | |
66 // Volume level from 0 to 1. | 89 // Volume level from 0 to 1. |
67 float volume_; | 90 float volume_; |
68 | 91 |
92 // Fixed playout hardware latency in frames. | |
93 double hardware_latency_frames_; | |
94 | |
69 DISALLOW_COPY_AND_ASSIGN(AUAudioOutputStream); | 95 DISALLOW_COPY_AND_ASSIGN(AUAudioOutputStream); |
70 }; | 96 }; |
71 | 97 |
72 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ | 98 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ |
OLD | NEW |