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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 source_(NULL), | 48 source_(NULL), |
49 device_(device), | 49 device_(device), |
50 audio_unit_(0), | 50 audio_unit_(0), |
51 volume_(1), | 51 volume_(1), |
52 hardware_latency_frames_(0), | 52 hardware_latency_frames_(0), |
53 stopped_(false), | 53 stopped_(false), |
54 current_hardware_pending_bytes_(0) { | 54 current_hardware_pending_bytes_(0) { |
55 // We must have a manager. | 55 // We must have a manager. |
56 DCHECK(manager_); | 56 DCHECK(manager_); |
57 | 57 |
58 VLOG(1) << "AUHALStream::AUHALStream()"; | 58 DVLOG(1) << "AUHALStream::AUHALStream()"; |
59 VLOG(1) << "Device: " << device; | 59 DVLOG(1) << "Device: " << device; |
60 VLOG(1) << "Output channels: " << output_channels_; | 60 DVLOG(1) << "Output channels: " << output_channels_; |
61 VLOG(1) << "Sample rate: " << params_.sample_rate(); | 61 DVLOG(1) << "Sample rate: " << params_.sample_rate(); |
62 VLOG(1) << "Buffer size: " << number_of_frames_; | 62 DVLOG(1) << "Buffer size: " << number_of_frames_; |
63 } | 63 } |
64 | 64 |
65 AUHALStream::~AUHALStream() { | 65 AUHALStream::~AUHALStream() { |
66 } | 66 } |
67 | 67 |
68 bool AUHALStream::Open() { | 68 bool AUHALStream::Open() { |
69 // Get the total number of output channels that the | 69 // Get the total number of output channels that the |
70 // hardware supports. | 70 // hardware supports. |
71 int device_output_channels; | 71 int device_output_channels; |
72 bool got_output_channels = AudioManagerMac::GetDeviceChannels( | 72 bool got_output_channels = AudioManagerMac::GetDeviceChannels( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 UInt32 bus_number, | 186 UInt32 bus_number, |
187 UInt32 number_of_frames, | 187 UInt32 number_of_frames, |
188 AudioBufferList* data) { | 188 AudioBufferList* data) { |
189 TRACE_EVENT0("audio", "AUHALStream::Render"); | 189 TRACE_EVENT0("audio", "AUHALStream::Render"); |
190 | 190 |
191 // If the stream parameters change for any reason, we need to insert a FIFO | 191 // If the stream parameters change for any reason, we need to insert a FIFO |
192 // since the OnMoreData() pipeline can't handle frame size changes. | 192 // since the OnMoreData() pipeline can't handle frame size changes. |
193 if (number_of_frames != number_of_frames_) { | 193 if (number_of_frames != number_of_frames_) { |
194 // Create a FIFO on the fly to handle any discrepancies in callback rates. | 194 // Create a FIFO on the fly to handle any discrepancies in callback rates. |
195 if (!audio_fifo_) { | 195 if (!audio_fifo_) { |
196 VLOG(1) << "Audio frame size changed from " << number_of_frames_ << " to " | 196 DVLOG(1) << "Audio frame size changed from " << number_of_frames_ |
197 << number_of_frames << "; adding FIFO to compensate."; | 197 << " to " << number_of_frames |
| 198 << "; adding FIFO to compensate."; |
198 audio_fifo_.reset(new AudioPullFifo( | 199 audio_fifo_.reset(new AudioPullFifo( |
199 output_channels_, | 200 output_channels_, |
200 number_of_frames_, | 201 number_of_frames_, |
201 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this)))); | 202 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this)))); |
202 } | 203 } |
203 } | 204 } |
204 | 205 |
205 // Make |output_bus_| wrap the output AudioBufferList. | 206 // Make |output_bus_| wrap the output AudioBufferList. |
206 WrapBufferList(data, output_bus_.get(), number_of_frames); | 207 WrapBufferList(data, output_bus_.get(), number_of_frames); |
207 | 208 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 result = AudioUnitInitialize(audio_unit_); | 435 result = AudioUnitInitialize(audio_unit_); |
435 if (result != noErr) { | 436 if (result != noErr) { |
436 OSSTATUS_DLOG(ERROR, result) << "AudioUnitInitialize() failed."; | 437 OSSTATUS_DLOG(ERROR, result) << "AudioUnitInitialize() failed."; |
437 return false; | 438 return false; |
438 } | 439 } |
439 | 440 |
440 return true; | 441 return true; |
441 } | 442 } |
442 | 443 |
443 } // namespace media | 444 } // namespace media |
OLD | NEW |