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

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

Issue 9418042: Adding microphone volume support to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed henrik's comments Created 8 years, 10 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 | Annotate | Revision Log
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 AudioDeviceID audio_device_id); 54 AudioDeviceID audio_device_id);
55 // The dtor is typically called by the AudioManager only and it is usually 55 // The dtor is typically called by the AudioManager only and it is usually
56 // triggered by calling AudioInputStream::Close(). 56 // triggered by calling AudioInputStream::Close().
57 virtual ~AUAudioInputStream(); 57 virtual ~AUAudioInputStream();
58 58
59 // Implementation of AudioInputStream. 59 // Implementation of AudioInputStream.
60 virtual bool Open() OVERRIDE; 60 virtual bool Open() OVERRIDE;
61 virtual void Start(AudioInputCallback* callback) OVERRIDE; 61 virtual void Start(AudioInputCallback* callback) OVERRIDE;
62 virtual void Stop() OVERRIDE; 62 virtual void Stop() OVERRIDE;
63 virtual void Close() OVERRIDE; 63 virtual void Close() OVERRIDE;
64 virtual double GetMaxVolume() OVERRIDE;
65 virtual void SetVolume(double volume) OVERRIDE;
66 virtual double GetVolume() OVERRIDE;
64 67
65 // Returns the current hardware sample rate for the default input device. 68 // Returns the current hardware sample rate for the default input device.
66 static double HardwareSampleRate(); 69 static double HardwareSampleRate();
67 70
68 bool started() const { return started_; } 71 bool started() const { return started_; }
69 AudioUnit audio_unit() { return audio_unit_; } 72 AudioUnit audio_unit() { return audio_unit_; }
70 AudioBufferList* audio_buffer_list() { return &audio_buffer_list_; } 73 AudioBufferList* audio_buffer_list() { return &audio_buffer_list_; }
71 74
72 private: 75 private:
73 // AudioOutputUnit callback. 76 // AudioOutputUnit callback.
74 static OSStatus InputProc(void* user_data, 77 static OSStatus InputProc(void* user_data,
75 AudioUnitRenderActionFlags* flags, 78 AudioUnitRenderActionFlags* flags,
76 const AudioTimeStamp* time_stamp, 79 const AudioTimeStamp* time_stamp,
77 UInt32 bus_number, 80 UInt32 bus_number,
78 UInt32 number_of_frames, 81 UInt32 number_of_frames,
79 AudioBufferList* io_data); 82 AudioBufferList* io_data);
80 83
81 // Pushes recorded data to consumer of the input audio stream. 84 // Pushes recorded data to consumer of the input audio stream.
82 OSStatus Provide(UInt32 number_of_frames, AudioBufferList* io_data, 85 OSStatus Provide(UInt32 number_of_frames, AudioBufferList* io_data,
83 const AudioTimeStamp* time_stamp); 86 const AudioTimeStamp* time_stamp);
84 87
85 // Gets the fixed capture hardware latency and store it during initialization. 88 // Gets the fixed capture hardware latency and store it during initialization.
86 // Returns 0 if not available. 89 // Returns 0 if not available.
87 double GetHardwareLatency(); 90 double GetHardwareLatency();
88 91
89 // Gets the current capture delay value. 92 // Gets the current capture delay value.
90 double GetCaptureLatency(const AudioTimeStamp* input_time_stamp); 93 double GetCaptureLatency(const AudioTimeStamp* input_time_stamp);
91 94
95 // Gets the number of channels for a stream of audio data.
96 UInt32 GetNumberOfChannelsFromStream();
tommi (sloooow) - chröme 2012/02/24 12:07:34 It looks like you've taken the UInt32 type from a
no longer working on chromium 2012/02/24 15:05:55 Done.
97
92 // Issues the OnError() callback to the |sink_|. 98 // Issues the OnError() callback to the |sink_|.
93 void HandleError(OSStatus err); 99 void HandleError(OSStatus err);
94 100
101 // Helper function to check if the volume control is avialable on specific
102 // channel.
103 bool IsVolumeSettableOnChannel(int channel);
104
95 // Our creator, the audio manager needs to be notified when we close. 105 // Our creator, the audio manager needs to be notified when we close.
96 AudioManagerMac* manager_; 106 AudioManagerMac* manager_;
97 107
98 // Contains the desired number of audio frames in each callback. 108 // Contains the desired number of audio frames in each callback.
99 size_t number_of_frames_; 109 size_t number_of_frames_;
100 110
101 // Pointer to the object that will receive the recorded audio samples. 111 // Pointer to the object that will receive the recorded audio samples.
102 AudioInputCallback* sink_; 112 AudioInputCallback* sink_;
103 113
104 // Structure that holds the desired output format of the stream. 114 // Structure that holds the desired output format of the stream.
(...skipping 14 matching lines...) Expand all
119 // Temporary storage for recorded data. The InputProc() renders into this 129 // Temporary storage for recorded data. The InputProc() renders into this
120 // array as soon as a frame of the desired buffer size has been recorded. 130 // array as soon as a frame of the desired buffer size has been recorded.
121 scoped_array<uint8> audio_data_buffer_; 131 scoped_array<uint8> audio_data_buffer_;
122 132
123 // True after successfull Start(), false after successful Stop(). 133 // True after successfull Start(), false after successful Stop().
124 bool started_; 134 bool started_;
125 135
126 // Fixed capture hardware latency in frames. 136 // Fixed capture hardware latency in frames.
127 double hardware_latency_frames_; 137 double hardware_latency_frames_;
128 138
139 // The number of channels in each frame of audio data, which is used
140 // when querying the volume of each channel.
141 UInt32 number_of_channels_in_frame_;
tommi (sloooow) - chröme 2012/02/24 12:07:34 is 32 bit necessary? int or size_t.
no longer working on chromium 2012/02/24 15:05:55 Done.
142
129 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); 143 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
130 }; 144 };
131 145
132 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ 146 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698