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

Unified Diff: media/base/audio_buffer.cc

Issue 212103013: Add channel_count parameter back to AudioBuffer creation methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mstr
Patch Set: fix unit test Created 6 years, 9 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/base/audio_buffer.h ('k') | media/base/audio_buffer_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer.cc
diff --git a/media/base/audio_buffer.cc b/media/base/audio_buffer.cc
index eba658bf02691b1e4377903a769454cf93af24e7..4b972b90a1abda47c363b0cd46c7c8362ca60ee2 100644
--- a/media/base/audio_buffer.cc
+++ b/media/base/audio_buffer.cc
@@ -13,6 +13,7 @@ namespace media {
AudioBuffer::AudioBuffer(SampleFormat sample_format,
ChannelLayout channel_layout,
+ int channel_count,
int sample_rate,
int frame_count,
bool create_buffer,
@@ -21,7 +22,7 @@ AudioBuffer::AudioBuffer(SampleFormat sample_format,
const base::TimeDelta duration)
: sample_format_(sample_format),
channel_layout_(channel_layout),
- channel_count_(ChannelLayoutToChannelCount(channel_layout)),
+ channel_count_(channel_count),
sample_rate_(sample_rate),
adjusted_frame_count_(frame_count),
trim_start_(0),
@@ -31,6 +32,9 @@ AudioBuffer::AudioBuffer(SampleFormat sample_format,
CHECK_GE(channel_count_, 0);
CHECK_LE(channel_count_, limits::kMaxChannels);
CHECK_GE(frame_count, 0);
+ DCHECK(channel_layout == CHANNEL_LAYOUT_DISCRETE ||
+ ChannelLayoutToChannelCount(channel_layout) == channel_count);
+
int bytes_per_channel = SampleFormatToBytesPerChannel(sample_format);
DCHECK_LE(bytes_per_channel, kChannelAlignment);
int data_size = frame_count * bytes_per_channel;
@@ -83,6 +87,7 @@ AudioBuffer::~AudioBuffer() {}
scoped_refptr<AudioBuffer> AudioBuffer::CopyFrom(
SampleFormat sample_format,
ChannelLayout channel_layout,
+ int channel_count,
int sample_rate,
int frame_count,
const uint8* const* data,
@@ -93,6 +98,7 @@ scoped_refptr<AudioBuffer> AudioBuffer::CopyFrom(
CHECK(data[0]);
return make_scoped_refptr(new AudioBuffer(sample_format,
channel_layout,
+ channel_count,
sample_rate,
frame_count,
true,
@@ -105,11 +111,13 @@ scoped_refptr<AudioBuffer> AudioBuffer::CopyFrom(
scoped_refptr<AudioBuffer> AudioBuffer::CreateBuffer(
SampleFormat sample_format,
ChannelLayout channel_layout,
+ int channel_count,
int sample_rate,
int frame_count) {
CHECK_GT(frame_count, 0); // Otherwise looks like an EOF buffer.
return make_scoped_refptr(new AudioBuffer(sample_format,
channel_layout,
+ channel_count,
sample_rate,
frame_count,
true,
@@ -121,6 +129,7 @@ scoped_refptr<AudioBuffer> AudioBuffer::CreateBuffer(
// static
scoped_refptr<AudioBuffer> AudioBuffer::CreateEmptyBuffer(
ChannelLayout channel_layout,
+ int channel_count,
int sample_rate,
int frame_count,
const base::TimeDelta timestamp,
@@ -129,6 +138,7 @@ scoped_refptr<AudioBuffer> AudioBuffer::CreateEmptyBuffer(
// Since data == NULL, format doesn't matter.
return make_scoped_refptr(new AudioBuffer(kSampleFormatF32,
channel_layout,
+ channel_count,
sample_rate,
frame_count,
false,
@@ -143,6 +153,7 @@ scoped_refptr<AudioBuffer> AudioBuffer::CreateEOSBuffer() {
CHANNEL_LAYOUT_NONE,
0,
0,
+ 0,
false,
NULL,
kNoTimestamp(),
« no previous file with comments | « media/base/audio_buffer.h ('k') | media/base/audio_buffer_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698