Index: media/base/audio_bus.cc |
diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc |
index 31e9e4f49cc215448cd95b60858d584a2b651370..1daa6a3712ace29c0c0ecf8f9a7c7b79170b3195 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_bitstream_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_bitstream_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_bitstream_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_bitstream_format_(false), |
+ channel_data_(channels), |
frames_(0), |
can_set_channel_data_(true) { |
CHECK_GT(channels, 0); |
@@ -158,8 +166,10 @@ void AudioBus::SetChannelData(int channel, float* data) { |
} |
void AudioBus::set_frames(int frames) { |
- CHECK(can_set_channel_data_); |
- ValidateConfig(static_cast<int>(channel_data_.size()), frames); |
+ if (!is_bitstream_format()) { |
DaleCurtis
2017/06/15 21:46:32
Why? Just change to CHECK(can_set_channel_data_ ||
AndyWu
2017/08/02 01:43:40
Done.
|
+ CHECK(can_set_channel_data_); |
+ ValidateConfig(static_cast<int>(channel_data_.size()), frames); |
+ } |
frames_ = frames; |
} |
@@ -308,6 +318,14 @@ void AudioBus::ToInterleavedPartial(int start_frame, |
} |
void AudioBus::CopyTo(AudioBus* dest) const { |
+ dest->set_is_bitstream_format(is_bitstream_format()); |
DaleCurtis
2017/06/15 21:46:32
Move inside? I don't think we need to worry about
AndyWu
2017/08/02 01:43:40
Not sure it's a good idea to assume the state of a
|
+ if (is_bitstream_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); |
} |