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

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

Issue 8234009: Adding input and output delay estimation for mac. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: replace deprecated AudioDevice* with AudioObject* & round the latency before converting to bytes Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 the moment getting the callback and the scheduled time
15 // stamp that tells when the data is going to be played out.
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
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. Returns 0
67 // if not available.
68 double GetHardwareLatency();
69
70 // Gets the current playout latency value.
71 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp);
72
52 // Our creator, the audio manager needs to be notified when we close. 73 // Our creator, the audio manager needs to be notified when we close.
53 AudioManagerMac* manager_; 74 AudioManagerMac* manager_;
54 75
55 size_t number_of_frames_; 76 size_t number_of_frames_;
56 77
57 // Pointer to the object that will provide the audio samples. 78 // Pointer to the object that will provide the audio samples.
58 AudioSourceCallback* source_; 79 AudioSourceCallback* source_;
59 80
60 // Structure that holds the stream format details such as bitrate. 81 // Structure that holds the stream format details such as bitrate.
61 AudioStreamBasicDescription format_; 82 AudioStreamBasicDescription format_;
62 83
63 // The default output Audio Unit which talks to the audio hardware. 84 // The default output Audio Unit which talks to the audio hardware.
64 AudioUnit output_unit_; 85 AudioUnit output_unit_;
65 86
87 // The UID refers to the current output audio device.
88 AudioDeviceID output_device_id_;
89
66 // Volume level from 0 to 1. 90 // Volume level from 0 to 1.
67 float volume_; 91 float volume_;
68 92
93 // Fixed playout hardware latency in frames.
94 double hardware_latency_frames_;
95
69 DISALLOW_COPY_AND_ASSIGN(AUAudioOutputStream); 96 DISALLOW_COPY_AND_ASSIGN(AUAudioOutputStream);
70 }; 97 };
71 98
72 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_ 99 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_OUTPUT_MAC_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac_unittest.cc ('k') | media/audio/mac/audio_low_latency_output_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698