OLD | NEW |
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_output_mac.h" | 5 #include "media/audio/mac/audio_low_latency_output_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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 int frames_filled = source_->OnMoreData( | 280 int frames_filled = source_->OnMoreData( |
281 audio_bus_.get(), AudioBuffersState(0, hardware_pending_bytes)); | 281 audio_bus_.get(), AudioBuffersState(0, hardware_pending_bytes)); |
282 | 282 |
283 // Note: If this ever changes to output raw float the data must be clipped and | 283 // Note: If this ever changes to output raw float the data must be clipped and |
284 // sanitized since it may come from an untrusted source such as NaCl. | 284 // sanitized since it may come from an untrusted source such as NaCl. |
285 audio_bus_->ToInterleaved( | 285 audio_bus_->ToInterleaved( |
286 frames_filled, format_.mBitsPerChannel / 8, audio_data); | 286 frames_filled, format_.mBitsPerChannel / 8, audio_data); |
287 uint32 filled = frames_filled * format_.mBytesPerFrame; | 287 uint32 filled = frames_filled * format_.mBytesPerFrame; |
288 | 288 |
| 289 // Perform in-place, software-volume adjustments. |
| 290 media::AdjustVolume(audio_data, |
| 291 filled, |
| 292 audio_bus_->channels(), |
| 293 format_.mBitsPerChannel / 8, |
| 294 volume_); |
| 295 |
289 // Handle channel order for 5.1 audio. | 296 // Handle channel order for 5.1 audio. |
290 // TODO(dalecurtis): Channel downmixing, upmixing, should be done in mixer; | 297 // TODO(dalecurtis): Channel downmixing, upmixing, should be done in mixer; |
291 // volume adjust should use SSE optimized vector_fmul() prior to interleave. | 298 // volume adjust should use SSE optimized vector_fmul() prior to interleave. |
292 if (format_.mChannelsPerFrame == 6) { | 299 if (format_.mChannelsPerFrame == 6) { |
293 if (format_.mBitsPerChannel == 8) { | 300 if (format_.mBitsPerChannel == 8) { |
294 SwizzleCoreAudioLayout5_1(reinterpret_cast<uint8*>(audio_data), filled); | 301 SwizzleCoreAudioLayout5_1(reinterpret_cast<uint8*>(audio_data), filled); |
295 } else if (format_.mBitsPerChannel == 16) { | 302 } else if (format_.mBitsPerChannel == 16) { |
296 SwizzleCoreAudioLayout5_1(reinterpret_cast<int16*>(audio_data), filled); | 303 SwizzleCoreAudioLayout5_1(reinterpret_cast<int16*>(audio_data), filled); |
297 } else if (format_.mBitsPerChannel == 32) { | 304 } else if (format_.mBitsPerChannel == 32) { |
298 SwizzleCoreAudioLayout5_1(reinterpret_cast<int32*>(audio_data), filled); | 305 SwizzleCoreAudioLayout5_1(reinterpret_cast<int32*>(audio_data), filled); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 if (now_ns > output_time_ns) | 423 if (now_ns > output_time_ns) |
417 return 0; | 424 return 0; |
418 | 425 |
419 double delay_frames = static_cast<double> | 426 double delay_frames = static_cast<double> |
420 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); | 427 (1e-9 * (output_time_ns - now_ns) * format_.mSampleRate); |
421 | 428 |
422 return (delay_frames + hardware_latency_frames_); | 429 return (delay_frames + hardware_latency_frames_); |
423 } | 430 } |
424 | 431 |
425 } // namespace media | 432 } // namespace media |
OLD | NEW |