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

Unified Diff: media/base/audio_bus.cc

Issue 10909185: Add Mac OS X synchronized audio I/O back-end (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
Index: media/base/audio_bus.cc
===================================================================
--- media/base/audio_bus.cc (revision 157152)
+++ media/base/audio_bus.cc (working copy)
@@ -105,7 +105,8 @@
}
AudioBus::AudioBus(int channels, int frames)
- : frames_(frames) {
+ : frames_(frames),
+ can_set_channel_data_(false) {
ValidateConfig(channels, frames_);
int aligned_frames = 0;
@@ -118,7 +119,8 @@
}
AudioBus::AudioBus(int channels, int frames, float* data)
- : frames_(frames) {
+ : frames_(frames),
+ can_set_channel_data_(false) {
ValidateConfig(channels, frames_);
int aligned_frames = 0;
@@ -129,7 +131,8 @@
AudioBus::AudioBus(int frames, const std::vector<float*>& channel_data)
: channel_data_(channel_data),
- frames_(frames) {
+ frames_(frames),
+ can_set_channel_data_(false) {
ValidateConfig(channel_data_.size(), frames_);
// Sanity check wrapped vector for alignment and channel count.
@@ -137,6 +140,14 @@
DCHECK(IsAligned(channel_data_[i]));
}
+AudioBus::AudioBus(int channels)
+ : channel_data_(channels),
+ frames_(0),
+ can_set_channel_data_(true) {
+ for (size_t i = 0; i < channel_data_.size(); ++i)
+ channel_data_[i] = NULL;
+}
+
AudioBus::~AudioBus() {}
scoped_ptr<AudioBus> AudioBus::Create(int channels, int frames) {
@@ -148,6 +159,10 @@
params.channels(), params.frames_per_buffer()));
}
+scoped_ptr<AudioBus> AudioBus::CreateWrapper(int channels) {
+ return scoped_ptr<AudioBus>(new AudioBus(channels));
+}
+
scoped_ptr<AudioBus> AudioBus::WrapVector(
int frames, const std::vector<float*>& channel_data) {
return scoped_ptr<AudioBus>(new AudioBus(frames, channel_data));
@@ -170,6 +185,19 @@
static_cast<float*>(data)));
}
+void AudioBus::SetChannelData(int channel, float* data) {
+ CHECK(can_set_channel_data_);
+ CHECK_GE(channel, 0);
+ CHECK_LT(static_cast<size_t>(channel), channel_data_.size());
+ DCHECK(IsAligned(data));
+ channel_data_[channel] = data;
+}
+
+void AudioBus::set_frames(int frames) {
+ CHECK(can_set_channel_data_);
+ frames_ = frames;
+}
+
void AudioBus::ZeroFramesPartial(int start_frame, int frames) {
CheckOverflow(start_frame, frames, frames_);

Powered by Google App Engine
This is Rietveld 408576698