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

Unified Diff: media/audio/android/opensles_output.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/android/opensles_output.h ('k') | media/audio/audio_device_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/android/opensles_output.cc
diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc
index 3b5ee648c7f846c425ab40e9db7a30815b6fe839..26ae25b6a0b355726542a20ff33bea90a963b0b1 100644
--- a/media/audio/android/opensles_output.cc
+++ b/media/audio/android/opensles_output.cc
@@ -35,6 +35,7 @@ OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
NOTREACHED() << "Unsupported number of channels: " << format_.numChannels;
buffer_size_bytes_ = params.GetBytesPerBuffer();
+ audio_bus_ = AudioBus::Create(params);
memset(&audio_data_, 0, sizeof(audio_data_));
}
@@ -257,17 +258,21 @@ void OpenSLESOutputStream::FillBufferQueue() {
// Read data from the registered client source.
// TODO(xians): Get an accurate delay estimation.
uint32 hardware_delay = buffer_size_bytes_;
- size_t num_filled_bytes = callback_->OnMoreData(
- audio_data_[active_queue_],
- buffer_size_bytes_,
- AudioBuffersState(0, hardware_delay));
- DCHECK(num_filled_bytes <= buffer_size_bytes_);
+ int frames_filled = callback_->OnMoreData(
+ audio_bus_.get(), AudioBuffersState(0, hardware_delay));
+ int num_filled_bytes =
+ frames_filled * audio_bus_->channels() * format_.bitsPerSample / 8;
+ DCHECK_LE(static_cast<size_t>(num_filled_bytes), buffer_size_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_.bitsPerSample / 8, audio_data_[active_queue_]);
// Perform in-place, software-volume adjustments.
media::AdjustVolume(audio_data_[active_queue_],
num_filled_bytes,
format_.numChannels,
- format_.containerSize >> 3,
+ format_.bitsPerSample / 8,
volume_);
// Enqueue the buffer for playback.
« no previous file with comments | « media/audio/android/opensles_output.h ('k') | media/audio/audio_device_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698