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

Unified Diff: media/audio/mac/audio_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_output_mac.h ('k') | media/audio/mac/audio_output_mac_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_output_mac.cc
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc
index 7f96735a495d6771b1e027740129cb7dcc95806a..0a0c321d33371bf2e076c497635088db8b9fe46c 100644
--- a/media/audio/mac/audio_output_mac.cc
+++ b/media/audio/mac/audio_output_mac.cc
@@ -53,7 +53,8 @@ PCMQueueOutAudioOutputStream::PCMQueueOutAudioOutputStream(
should_swizzle_(false),
should_down_mix_(false),
stopped_event_(true /* manual reset */, false /* initial state */),
- num_buffers_left_(kNumBuffers) {
+ num_buffers_left_(kNumBuffers),
+ 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
@@ -409,11 +410,20 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this,
// Adjust the number of pending bytes by subtracting the amount played.
if (!static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer)
audio_stream->pending_bytes_ -= buffer->mAudioDataByteSize;
+
uint32 capacity = buffer->mAudioDataBytesCapacity;
+ AudioBus* audio_bus = audio_stream->audio_bus_.get();
+ DCHECK_EQ(
+ audio_bus->frames() * audio_stream->format_.mBytesPerFrame, capacity);
// TODO(sergeyu): Specify correct hardware delay for AudioBuffersState.
- uint32 filled = source->OnMoreData(
- reinterpret_cast<uint8*>(buffer->mAudioData), capacity,
- AudioBuffersState(audio_stream->pending_bytes_, 0));
+ int frames_filled = source->OnMoreData(
+ audio_bus, AudioBuffersState(audio_stream->pending_bytes_, 0));
+ uint32 filled = frames_filled * audio_stream->format_.mBytesPerFrame;
+ // 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, audio_stream->format_.mBitsPerChannel / 8,
+ buffer->mAudioData);
// In order to keep the callback running, we need to provide a positive amount
// of data to the audio queue. To simulate the behavior of Windows, we write
« no previous file with comments | « media/audio/mac/audio_output_mac.h ('k') | media/audio/mac/audio_output_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698