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

Unified Diff: media/audio/mac/audio_low_latency_output_mac.cc

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Comments. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/mac/audio_low_latency_output_mac.h ('k') | media/audio/mac/audio_output_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_low_latency_output_mac.cc
diff --git a/media/audio/mac/audio_low_latency_output_mac.cc b/media/audio/mac/audio_low_latency_output_mac.cc
index d9127f8d2824b1c7040d10d71c8c83d10b49fb49..b9248dc25467ed52249340cda87c79d40240151f 100644
--- a/media/audio/mac/audio_low_latency_output_mac.cc
+++ b/media/audio/mac/audio_low_latency_output_mac.cc
@@ -53,7 +53,8 @@ AUAudioOutputStream::AUAudioOutputStream(
output_device_id_(kAudioObjectUnknown),
volume_(1),
hardware_latency_frames_(0),
- stopped_(false) {
+ stopped_(false),
+ audio_bus_(AudioBus::Create(params)) {
// We must have a manager.
DCHECK(manager_);
// A frame is one sample across all channels. In interleaved audio the per
@@ -226,11 +227,19 @@ OSStatus AUAudioOutputStream::Render(UInt32 number_of_frames,
uint8* audio_data = reinterpret_cast<uint8*>(buffer.mData);
uint32 hardware_pending_bytes = static_cast<uint32>
((playout_latency_frames + 0.5) * format_.mBytesPerFrame);
- uint32 filled = source_->OnMoreData(
- audio_data, buffer.mDataByteSize,
- AudioBuffersState(0, hardware_pending_bytes));
+
+ DCHECK_EQ(number_of_frames, static_cast<UInt32>(audio_bus_->frames()));
+ int frames_filled = source_->OnMoreData(
+ audio_bus_.get(), AudioBuffersState(0, hardware_pending_bytes));
+ // Note: If this ever changes to output raw float the data must be clipped and
+ // sanitized since it may come from an untrusted source such as NaCl.
+ audio_bus_->ToInterleaved(
+ frames_filled, format_.mBitsPerChannel / 8, audio_data);
+ uint32 filled = frames_filled * format_.mBytesPerFrame;
// Handle channel order for 5.1 audio.
+ // TODO(dalecurtis): Channel downmixing, upmixing, should be done in mixer;
+ // volume adjust should use SSE optimized vector_fmul() prior to interleave.
if (format_.mChannelsPerFrame == 6) {
if (format_.mBitsPerChannel == 8) {
SwizzleCoreAudioLayout5_1(reinterpret_cast<uint8*>(audio_data), filled);
« no previous file with comments | « media/audio/mac/audio_low_latency_output_mac.h ('k') | media/audio/mac/audio_output_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698