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

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

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the bots. Created 7 years, 9 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 #include "media/audio/mac/audio_low_latency_input_mac.h" 5 #include "media/audio/mac/audio_low_latency_input_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 format_.mReserved = 0; 60 format_.mReserved = 0;
61 61
62 DVLOG(1) << "Desired ouput format: " << format_; 62 DVLOG(1) << "Desired ouput format: " << format_;
63 63
64 // Set number of sample frames per callback used by the internal audio layer. 64 // Set number of sample frames per callback used by the internal audio layer.
65 // An internal FIFO is then utilized to adapt the internal size to the size 65 // An internal FIFO is then utilized to adapt the internal size to the size
66 // requested by the client. 66 // requested by the client.
67 // Note that we use the same native buffer size as for the output side here 67 // Note that we use the same native buffer size as for the output side here
68 // since the AUHAL implementation requires that both capture and render side 68 // since the AUHAL implementation requires that both capture and render side
69 // use the same buffer size. See http://crbug.com/154352 for more details. 69 // use the same buffer size. See http://crbug.com/154352 for more details.
70 number_of_frames_ = GetAudioHardwareBufferSize(); 70 const AudioParameters parameters =
71 manager_->GetInputStreamParameters(input_device_id_);
72 number_of_frames_ = parameters.frames_per_buffer();
71 DVLOG(1) << "Size of data buffer in frames : " << number_of_frames_; 73 DVLOG(1) << "Size of data buffer in frames : " << number_of_frames_;
72 74
73 // Derive size (in bytes) of the buffers that we will render to. 75 // Derive size (in bytes) of the buffers that we will render to.
74 UInt32 data_byte_size = number_of_frames_ * format_.mBytesPerFrame; 76 UInt32 data_byte_size = number_of_frames_ * format_.mBytesPerFrame;
75 DVLOG(1) << "Size of data buffer in bytes : " << data_byte_size; 77 DVLOG(1) << "Size of data buffer in bytes : " << data_byte_size;
76 78
77 // Allocate AudioBuffers to be used as storage for the received audio. 79 // Allocate AudioBuffers to be used as storage for the received audio.
78 // The AudioBufferList structure works as a placeholder for the 80 // The AudioBufferList structure works as a placeholder for the
79 // AudioBuffer structure, which holds a pointer to the actual data buffer. 81 // AudioBuffer structure, which holds a pointer to the actual data buffer.
80 audio_data_buffer_.reset(new uint8[data_byte_size]); 82 audio_data_buffer_.reset(new uint8[data_byte_size]);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 &format_, 220 &format_,
219 sizeof(format_)); 221 sizeof(format_));
220 if (result) { 222 if (result) {
221 HandleError(result); 223 HandleError(result);
222 return false; 224 return false;
223 } 225 }
224 226
225 // Set the desired number of frames in the IO buffer (output scope). 227 // Set the desired number of frames in the IO buffer (output scope).
226 // WARNING: Setting this value changes the frame size for all audio units in 228 // WARNING: Setting this value changes the frame size for all audio units in
227 // the current process. It's imperative that the input and output frame sizes 229 // the current process. It's imperative that the input and output frame sizes
228 // be the same as audio_util::GetAudioHardwareBufferSize(). 230 // be the same as the frames_per_buffer() returned by
231 // GetInputStreamParameters().
229 // TODO(henrika): Due to http://crrev.com/159666 this is currently not true 232 // TODO(henrika): Due to http://crrev.com/159666 this is currently not true
230 // and should be fixed, a CHECK() should be added at that time. 233 // and should be fixed, a CHECK() should be added at that time.
231 result = AudioUnitSetProperty(audio_unit_, 234 result = AudioUnitSetProperty(audio_unit_,
232 kAudioDevicePropertyBufferFrameSize, 235 kAudioDevicePropertyBufferFrameSize,
233 kAudioUnitScope_Output, 236 kAudioUnitScope_Output,
234 1, 237 1,
235 &number_of_frames_, // size is set in the ctor 238 &number_of_frames_, // size is set in the ctor
236 sizeof(number_of_frames_)); 239 sizeof(number_of_frames_));
237 if (result) { 240 if (result) {
238 HandleError(result); 241 HandleError(result);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 kAudioDevicePropertyScopeInput, 650 kAudioDevicePropertyScopeInput,
648 static_cast<UInt32>(channel) 651 static_cast<UInt32>(channel)
649 }; 652 };
650 OSStatus result = AudioObjectIsPropertySettable(input_device_id_, 653 OSStatus result = AudioObjectIsPropertySettable(input_device_id_,
651 &property_address, 654 &property_address,
652 &is_settable); 655 &is_settable);
653 return (result == noErr) ? is_settable : false; 656 return (result == noErr) ? is_settable : false;
654 } 657 }
655 658
656 } // namespace media 659 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698