Commit 686d2111 authored by henrika's avatar henrika Committed by Commit bot

Initialize input AUHAL before using it.

This CL is an attempt to ensure that input audio recording always works on Mac OS X.
It is a trivial change and I don't know if it has any real effect, hence it is speculative.
I am making this change since I have seen in examples that it is recommended to initialize
the AUHAL before using it. We can only hope that it has a positive effect.
More small changes are in the pipeline but my plan was to land them one by one to keep
the changes as simple as possible and easy to revert if needed.

Adding tommi@ as TBR since he is OOO and the change can be considered trivial. If we are lucky
it has a positive effect. If we are not, I don't expect any effect at all.

TBR=tommi
BUG=549021

Review URL: https://codereview.chromium.org/1551613002

Cr-Commit-Position: refs/heads/master@{#366977}
parent be7232f7
...@@ -79,7 +79,7 @@ AUAudioInputStream::AUAudioInputStream(AudioManagerMac* manager, ...@@ -79,7 +79,7 @@ AUAudioInputStream::AUAudioInputStream(AudioManagerMac* manager,
format_.mBytesPerFrame = format_.mBytesPerPacket; format_.mBytesPerFrame = format_.mBytesPerPacket;
format_.mReserved = 0; format_.mReserved = 0;
DVLOG(1) << "Desired ouput format: " << format_; DVLOG(1) << "Desired output (client side) format: " << format_;
// Derive size (in bytes) of the buffers that we will render to. // Derive size (in bytes) of the buffers that we will render to.
UInt32 data_byte_size = number_of_frames_ * format_.mBytesPerFrame; UInt32 data_byte_size = number_of_frames_ * format_.mBytesPerFrame;
...@@ -134,6 +134,10 @@ bool AUAudioInputStream::Open() { ...@@ -134,6 +134,10 @@ bool AUAudioInputStream::Open() {
// Obtain an AudioOuputUnit using an AUHAL component description. // Obtain an AudioOuputUnit using an AUHAL component description.
// Description for the Audio Unit we want to use (AUHAL in this case). // Description for the Audio Unit we want to use (AUHAL in this case).
// The kAudioUnitSubType_HALOutput audio unit interfaces to any audio device.
// The user specifies which audio device to track. The audio unit can do
// input from the device as well as output to the device. Bus 0 is used for
// the output side, bus 1 is used to get audio input from the device.
AudioComponentDescription desc = { AudioComponentDescription desc = {
kAudioUnitType_Output, kAudioUnitType_Output,
kAudioUnitSubType_HALOutput, kAudioUnitSubType_HALOutput,
...@@ -142,7 +146,7 @@ bool AUAudioInputStream::Open() { ...@@ -142,7 +146,7 @@ bool AUAudioInputStream::Open() {
0 0
}; };
AudioComponent comp = AudioComponentFindNext(0, &desc); AudioComponent comp = AudioComponentFindNext(NULL, &desc);
DCHECK(comp); DCHECK(comp);
// Get access to the service provided by the specified Audio Unit. // Get access to the service provided by the specified Audio Unit.
...@@ -152,6 +156,13 @@ bool AUAudioInputStream::Open() { ...@@ -152,6 +156,13 @@ bool AUAudioInputStream::Open() {
return false; return false;
} }
// Initialize the AUHAL before making any changes or using it.
result = AudioUnitInitialize(audio_unit_);
if (result != noErr) {
HandleError(result);
return false;
}
// Enable IO on the input scope of the Audio Unit. // Enable IO on the input scope of the Audio Unit.
// After creating the AUHAL object, we must enable IO on the input scope // After creating the AUHAL object, we must enable IO on the input scope
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment