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

Unified Diff: media/base/audio_bus.cc

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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
diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc
index d261e87f8dc9f26ae29338b874343eebf728f275..e46b27ea83c3537c8f27522e52a68a02a5e12e07 100644
--- a/media/base/audio_bus.cc
+++ b/media/base/audio_bus.cc
@@ -62,7 +62,9 @@ void AudioBus::CheckOverflow(int start_frame, int frames, int total_frames) {
}
AudioBus::AudioBus(int channels, int frames)
- : frames_(frames),
+ : data_size_(0),
+ is_raw_format_(false),
+ frames_(frames),
can_set_channel_data_(false) {
ValidateConfig(channels, frames_);
@@ -76,7 +78,9 @@ AudioBus::AudioBus(int channels, int frames)
}
AudioBus::AudioBus(int channels, int frames, float* data)
- : frames_(frames),
+ : data_size_(0),
+ is_raw_format_(false),
+ frames_(frames),
can_set_channel_data_(false) {
// Since |data| may have come from an external source, ensure it's valid.
CHECK(data);
@@ -89,7 +93,9 @@ AudioBus::AudioBus(int channels, int frames, float* data)
}
AudioBus::AudioBus(int frames, const std::vector<float*>& channel_data)
- : channel_data_(channel_data),
+ : data_size_(0),
+ is_raw_format_(false),
+ channel_data_(channel_data),
frames_(frames),
can_set_channel_data_(false) {
ValidateConfig(
@@ -101,7 +107,9 @@ AudioBus::AudioBus(int frames, const std::vector<float*>& channel_data)
}
AudioBus::AudioBus(int channels)
- : channel_data_(channels),
+ : data_size_(0),
+ is_raw_format_(false),
+ channel_data_(channels),
frames_(0),
can_set_channel_data_(true) {
CHECK_GT(channels, 0);
@@ -157,9 +165,19 @@ void AudioBus::SetChannelData(int channel, float* data) {
channel_data_[channel] = data;
}
+void AudioBus::set_data_size(int data_size) {
+ data_size_ = data_size;
+}
+
+void AudioBus::set_is_raw_format(bool is_raw_format) {
+ is_raw_format_ = is_raw_format;
+}
+
void AudioBus::set_frames(int frames) {
- CHECK(can_set_channel_data_);
- ValidateConfig(static_cast<int>(channel_data_.size()), frames);
+ if (!is_raw_format()) {
+ CHECK(can_set_channel_data_);
+ ValidateConfig(static_cast<int>(channel_data_.size()), frames);
+ }
frames_ = frames;
}
@@ -308,6 +326,14 @@ void AudioBus::ToInterleavedPartial(int start_frame,
}
void AudioBus::CopyTo(AudioBus* dest) const {
+ dest->set_is_raw_format(is_raw_format());
+ if (is_raw_format()) {
+ dest->set_data_size(data_size());
+ dest->set_frames(frames());
+ memcpy(dest->channel(0), channel(0), data_size());
+ return;
+ }
+
CopyPartialFramesTo(0, frames(), 0, dest);
}

Powered by Google App Engine
This is Rietveld 408576698