Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_auhal_mac.h" | 5 #include "media/audio/mac/audio_auhal_mac.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstddef> | 10 #include <cstddef> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 107 |
| 108 ReportAndResetStats(); | 108 ReportAndResetStats(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool AUHALStream::Open() { | 111 bool AUHALStream::Open() { |
| 112 DCHECK(thread_checker_.CalledOnValidThread()); | 112 DCHECK(thread_checker_.CalledOnValidThread()); |
| 113 DCHECK(!output_bus_.get()); | 113 DCHECK(!output_bus_.get()); |
| 114 DCHECK(!audio_unit_); | 114 DCHECK(!audio_unit_); |
| 115 DVLOG(1) << "Open"; | 115 DVLOG(1) << "Open"; |
| 116 | 116 |
| 117 // Get the total number of output channels that the | |
|
DaleCurtis
2017/03/23 22:15:03
Deleted this since it's enforced by the AudioOutpu
| |
| 118 // hardware supports. | |
| 119 int device_output_channels; | |
| 120 bool got_output_channels = AudioManagerMac::GetDeviceChannels( | |
| 121 device_, | |
| 122 kAudioDevicePropertyScopeOutput, | |
| 123 &device_output_channels); | |
| 124 | |
| 125 // Sanity check the requested output channels. | |
| 126 if (!got_output_channels || | |
| 127 output_channels_ <= 0 || output_channels_ > device_output_channels) { | |
| 128 LOG(ERROR) << "AudioDevice does not support requested output channels."; | |
| 129 return false; | |
| 130 } | |
| 131 | |
| 132 // The requested sample-rate must match the hardware sample-rate. | |
| 133 int sample_rate = AudioManagerMac::HardwareSampleRateForDevice(device_); | |
| 134 | |
| 135 if (sample_rate != params_.sample_rate()) { | |
| 136 LOG(ERROR) << "Requested sample-rate: " << params_.sample_rate() | |
| 137 << " must match the hardware sample-rate: " << sample_rate; | |
| 138 return false; | |
| 139 } | |
| 140 | |
| 141 // The output bus will wrap the AudioBufferList given to us in | 117 // The output bus will wrap the AudioBufferList given to us in |
| 142 // the Render() callback. | 118 // the Render() callback. |
| 143 DCHECK_GT(output_channels_, 0); | 119 DCHECK_GT(output_channels_, 0); |
| 144 output_bus_ = AudioBus::CreateWrapper(output_channels_); | 120 output_bus_ = AudioBus::CreateWrapper(output_channels_); |
| 145 | 121 |
| 146 bool configured = ConfigureAUHAL(); | 122 bool configured = ConfigureAUHAL(); |
| 147 if (configured) | 123 if (configured) |
| 148 hardware_latency_ = GetHardwareLatency(); | 124 hardware_latency_ = GetHardwareLatency(); |
| 149 | 125 |
| 150 return configured; | 126 return configured; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 OSStatus result = AudioUnitSetProperty( | 613 OSStatus result = AudioUnitSetProperty( |
| 638 audio_unit_, kAudioUnitProperty_AudioChannelLayout, kAudioUnitScope_Input, | 614 audio_unit_, kAudioUnitProperty_AudioChannelLayout, kAudioUnitScope_Input, |
| 639 0, channel_layout, layout_size); | 615 0, channel_layout, layout_size); |
| 640 if (result != noErr) { | 616 if (result != noErr) { |
| 641 OSSTATUS_DLOG(ERROR, result) | 617 OSSTATUS_DLOG(ERROR, result) |
| 642 << "Failed to set audio channel layout. Using default layout."; | 618 << "Failed to set audio channel layout. Using default layout."; |
| 643 } | 619 } |
| 644 } | 620 } |
| 645 | 621 |
| 646 } // namespace media | 622 } // namespace media |
| OLD | NEW |