Convert channel counts to size_t.

IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.

BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org

Review URL: https://codereview.webrtc.org/1316523002 .

Cr-Commit-Position: refs/heads/master@{#11229}
This commit is contained in:
Peter Kasting 2016-01-12 16:26:35 -08:00
parent 92e677a1f8
commit 6955870806
190 changed files with 892 additions and 868 deletions

View File

@ -151,7 +151,7 @@ class AudioTrackSinkInterface {
virtual void OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) = 0;
protected:

View File

@ -44,7 +44,7 @@ LocalAudioSinkAdapter::~LocalAudioSinkAdapter() {
void LocalAudioSinkAdapter::OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) {
rtc::CritScope lock(&lock_);
if (sink_) {

View File

@ -57,7 +57,7 @@ class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
void OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) override;
// cricket::AudioRenderer implementation.

View File

@ -58,7 +58,7 @@ class FakeAdmTest : public testing::Test,
int32_t RecordedDataIsAvailable(const void* audioSamples,
const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
const uint32_t totalDelayMS,
const int32_t clockDrift,
@ -82,7 +82,7 @@ class FakeAdmTest : public testing::Test,
// ADM is pulling data.
int32_t NeedMorePlayData(const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
void* audioSamples,
size_t& nSamplesOut,

View File

@ -2064,7 +2064,7 @@ static bool ParseDtlsSetup(const std::string& line,
struct StaticPayloadAudioCodec {
const char* name;
int clockrate;
int channels;
size_t channels;
};
static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = {
{ "PCMU", 8000, 1 },
@ -2103,7 +2103,7 @@ void MaybeCreateStaticPayloadAudioCodecs(
payload_type < arraysize(kStaticPayloadAudioCodecs)) {
std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name;
int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate;
int channels = kStaticPayloadAudioCodecs[payload_type].channels;
size_t channels = kStaticPayloadAudioCodecs[payload_type].channels;
media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name,
clock_rate, 0, channels,
preference));
@ -2838,7 +2838,7 @@ bool ParseCryptoAttribute(const std::string& line,
// Updates or creates a new codec entry in the audio description with according
// to |name|, |clockrate|, |bitrate|, |channels| and |preference|.
void UpdateCodec(int payload_type, const std::string& name, int clockrate,
int bitrate, int channels, int preference,
int bitrate, size_t channels, int preference,
AudioContentDescription* audio_desc) {
// Codec may already be populated with (only) optional parameters
// (from an fmtp).
@ -2937,7 +2937,7 @@ bool ParseRtpmapAttribute(const std::string& line,
// of audio channels. This parameter is OPTIONAL and may be
// omitted if the number of channels is one, provided that no
// additional parameters are needed.
int channels = 1;
size_t channels = 1;
if (codec_params.size() == 3) {
if (!GetValueFromString(line, codec_params[2], &channels, error)) {
return false;

View File

@ -41,7 +41,7 @@ class AudioRenderer {
virtual void OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) = 0;
// Called when the AudioRenderer is going away.

View File

@ -167,7 +167,7 @@ AudioCodec::AudioCodec(int id,
const std::string& name,
int clockrate,
int bitrate,
int channels,
size_t channels,
int preference)
: Codec(id, name, clockrate, preference),
bitrate(bitrate),

View File

@ -128,14 +128,14 @@ struct Codec {
struct AudioCodec : public Codec {
int bitrate;
int channels;
size_t channels;
// Creates a codec with the given parameters.
AudioCodec(int id,
const std::string& name,
int clockrate,
int bitrate,
int channels,
size_t channels,
int preference);
// Creates an empty codec.
AudioCodec();

View File

@ -368,7 +368,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
void OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) override {}
void OnClose() override { renderer_ = NULL; }
AudioRenderer* renderer() const { return renderer_; }

View File

@ -77,10 +77,10 @@ class FakeAudioProcessing : public webrtc::AudioProcessing {
WEBRTC_STUB_CONST(input_sample_rate_hz, ());
WEBRTC_STUB_CONST(proc_sample_rate_hz, ());
WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ());
WEBRTC_STUB_CONST(num_input_channels, ());
WEBRTC_STUB_CONST(num_proc_channels, ());
WEBRTC_STUB_CONST(num_output_channels, ());
WEBRTC_STUB_CONST(num_reverse_channels, ());
size_t num_input_channels() const override { return 0; }
size_t num_proc_channels() const override { return 0; }
size_t num_output_channels() const override { return 0; }
size_t num_reverse_channels() const override { return 0; }
WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted));
WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame));
WEBRTC_STUB(ProcessStream, (

View File

@ -410,7 +410,7 @@ class WebRtcVoiceCodecs final {
struct CodecPref {
const char* name;
int clockrate;
int channels;
size_t channels;
int payload_type;
bool is_multi_rate;
int packet_sizes_ms[kMaxNumPacketSize];
@ -1155,7 +1155,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
void OnData(const void* audio_data,
int bits_per_sample,
int sample_rate,
int number_of_channels,
size_t number_of_channels,
size_t number_of_frames) override {
RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread());
RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread());

View File

@ -30,7 +30,7 @@ class AudioSinkInterface {
Data(int16_t* data,
size_t samples_per_channel,
int sample_rate,
int channels,
size_t channels,
uint32_t timestamp)
: data(data),
samples_per_channel(samples_per_channel),
@ -41,7 +41,7 @@ class AudioSinkInterface {
int16_t* data; // The actual 16bit audio data.
size_t samples_per_channel; // Number of frames in the buffer.
int sample_rate; // Sample rate in Hz.
int channels; // Number of channels in the audio data.
size_t channels; // Number of channels in the audio data.
uint32_t timestamp; // The RTP timestamp of the first sample.
};

View File

@ -25,7 +25,7 @@ namespace webrtc {
class CopyConverter : public AudioConverter {
public:
CopyConverter(int src_channels, size_t src_frames, int dst_channels,
CopyConverter(size_t src_channels, size_t src_frames, size_t dst_channels,
size_t dst_frames)
: AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {}
~CopyConverter() override {};
@ -34,7 +34,7 @@ class CopyConverter : public AudioConverter {
size_t dst_capacity) override {
CheckSizes(src_size, dst_capacity);
if (src != dst) {
for (int i = 0; i < src_channels(); ++i)
for (size_t i = 0; i < src_channels(); ++i)
std::memcpy(dst[i], src[i], dst_frames() * sizeof(*dst[i]));
}
}
@ -42,7 +42,7 @@ class CopyConverter : public AudioConverter {
class UpmixConverter : public AudioConverter {
public:
UpmixConverter(int src_channels, size_t src_frames, int dst_channels,
UpmixConverter(size_t src_channels, size_t src_frames, size_t dst_channels,
size_t dst_frames)
: AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {}
~UpmixConverter() override {};
@ -52,7 +52,7 @@ class UpmixConverter : public AudioConverter {
CheckSizes(src_size, dst_capacity);
for (size_t i = 0; i < dst_frames(); ++i) {
const float value = src[0][i];
for (int j = 0; j < dst_channels(); ++j)
for (size_t j = 0; j < dst_channels(); ++j)
dst[j][i] = value;
}
}
@ -60,7 +60,7 @@ class UpmixConverter : public AudioConverter {
class DownmixConverter : public AudioConverter {
public:
DownmixConverter(int src_channels, size_t src_frames, int dst_channels,
DownmixConverter(size_t src_channels, size_t src_frames, size_t dst_channels,
size_t dst_frames)
: AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {
}
@ -72,7 +72,7 @@ class DownmixConverter : public AudioConverter {
float* dst_mono = dst[0];
for (size_t i = 0; i < src_frames(); ++i) {
float sum = 0;
for (int j = 0; j < src_channels(); ++j)
for (size_t j = 0; j < src_channels(); ++j)
sum += src[j][i];
dst_mono[i] = sum / src_channels();
}
@ -81,11 +81,11 @@ class DownmixConverter : public AudioConverter {
class ResampleConverter : public AudioConverter {
public:
ResampleConverter(int src_channels, size_t src_frames, int dst_channels,
ResampleConverter(size_t src_channels, size_t src_frames, size_t dst_channels,
size_t dst_frames)
: AudioConverter(src_channels, src_frames, dst_channels, dst_frames) {
resamplers_.reserve(src_channels);
for (int i = 0; i < src_channels; ++i)
for (size_t i = 0; i < src_channels; ++i)
resamplers_.push_back(new PushSincResampler(src_frames, dst_frames));
}
~ResampleConverter() override {};
@ -136,9 +136,9 @@ class CompositionConverter : public AudioConverter {
ScopedVector<ChannelBuffer<float>> buffers_;
};
rtc::scoped_ptr<AudioConverter> AudioConverter::Create(int src_channels,
rtc::scoped_ptr<AudioConverter> AudioConverter::Create(size_t src_channels,
size_t src_frames,
int dst_channels,
size_t dst_channels,
size_t dst_frames) {
rtc::scoped_ptr<AudioConverter> sp;
if (src_channels > dst_channels) {
@ -183,8 +183,8 @@ AudioConverter::AudioConverter()
dst_channels_(0),
dst_frames_(0) {}
AudioConverter::AudioConverter(int src_channels, size_t src_frames,
int dst_channels, size_t dst_frames)
AudioConverter::AudioConverter(size_t src_channels, size_t src_frames,
size_t dst_channels, size_t dst_frames)
: src_channels_(src_channels),
src_frames_(src_frames),
dst_channels_(dst_channels),

View File

@ -26,9 +26,9 @@ class AudioConverter {
public:
// Returns a new AudioConverter, which will use the supplied format for its
// lifetime. Caller is responsible for the memory.
static rtc::scoped_ptr<AudioConverter> Create(int src_channels,
static rtc::scoped_ptr<AudioConverter> Create(size_t src_channels,
size_t src_frames,
int dst_channels,
size_t dst_channels,
size_t dst_frames);
virtual ~AudioConverter() {};
@ -39,23 +39,23 @@ class AudioConverter {
virtual void Convert(const float* const* src, size_t src_size,
float* const* dst, size_t dst_capacity) = 0;
int src_channels() const { return src_channels_; }
size_t src_channels() const { return src_channels_; }
size_t src_frames() const { return src_frames_; }
int dst_channels() const { return dst_channels_; }
size_t dst_channels() const { return dst_channels_; }
size_t dst_frames() const { return dst_frames_; }
protected:
AudioConverter();
AudioConverter(int src_channels, size_t src_frames, int dst_channels,
AudioConverter(size_t src_channels, size_t src_frames, size_t dst_channels,
size_t dst_frames);
// Helper to RTC_CHECK that inputs are correctly sized.
void CheckSizes(size_t src_size, size_t dst_capacity) const;
private:
const int src_channels_;
const size_t src_channels_;
const size_t src_frames_;
const int dst_channels_;
const size_t dst_channels_;
const size_t dst_frames_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioConverter);

View File

@ -26,9 +26,9 @@ typedef rtc::scoped_ptr<ChannelBuffer<float>> ScopedBuffer;
// Sets the signal value to increase by |data| with every sample.
ScopedBuffer CreateBuffer(const std::vector<float>& data, size_t frames) {
const int num_channels = static_cast<int>(data.size());
const size_t num_channels = data.size();
ScopedBuffer sb(new ChannelBuffer<float>(frames, num_channels));
for (int i = 0; i < num_channels; ++i)
for (size_t i = 0; i < num_channels; ++i)
for (size_t j = 0; j < frames; ++j)
sb->channels()[i][j] = data[i] * j;
return sb;
@ -57,7 +57,7 @@ float ComputeSNR(const ChannelBuffer<float>& ref,
float mse = 0;
float variance = 0;
float mean = 0;
for (int i = 0; i < ref.num_channels(); ++i) {
for (size_t i = 0; i < ref.num_channels(); ++i) {
for (size_t j = 0; j < ref.num_frames() - delay; ++j) {
float error = ref.channels()[i][j] - test.channels()[i][j + delay];
mse += error * error;
@ -86,9 +86,9 @@ float ComputeSNR(const ChannelBuffer<float>& ref,
// Sets the source to a linearly increasing signal for which we can easily
// generate a reference. Runs the AudioConverter and ensures the output has
// sufficiently high SNR relative to the reference.
void RunAudioConverterTest(int src_channels,
void RunAudioConverterTest(size_t src_channels,
int src_sample_rate_hz,
int dst_channels,
size_t dst_channels,
int dst_sample_rate_hz) {
const float kSrcLeft = 0.0002f;
const float kSrcRight = 0.0001f;
@ -128,8 +128,9 @@ void RunAudioConverterTest(int src_channels,
static_cast<size_t>(
PushSincResampler::AlgorithmicDelaySeconds(src_sample_rate_hz) *
dst_sample_rate_hz);
printf("(%d, %d Hz) -> (%d, %d Hz) ", // SNR reported on the same line later.
src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz);
// SNR reported on the same line later.
printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ",
src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz);
rtc::scoped_ptr<AudioConverter> converter = AudioConverter::Create(
src_channels, src_frames, dst_channels, dst_frames);
@ -142,7 +143,7 @@ void RunAudioConverterTest(int src_channels,
TEST(AudioConverterTest, ConversionsPassSNRThreshold) {
const int kSampleRates[] = {8000, 16000, 32000, 44100, 48000};
const int kChannels[] = {1, 2};
const size_t kChannels[] = {1, 2};
for (size_t src_rate = 0; src_rate < arraysize(kSampleRates); ++src_rate) {
for (size_t dst_rate = 0; dst_rate < arraysize(kSampleRates); ++dst_rate) {
for (size_t src_channel = 0; src_channel < arraysize(kChannels);

View File

@ -22,10 +22,10 @@ void AddFrames(const float* const* a,
const float* const* b,
int b_start_index,
size_t num_frames,
int num_channels,
size_t num_channels,
float* const* result,
size_t result_start_index) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
result[i][j + result_start_index] =
a[i][j + a_start_index] + b[i][j + b_start_index];
@ -37,10 +37,10 @@ void AddFrames(const float* const* a,
void CopyFrames(const float* const* src,
size_t src_start_index,
size_t num_frames,
int num_channels,
size_t num_channels,
float* const* dst,
size_t dst_start_index) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
memcpy(&dst[i][dst_start_index],
&src[i][src_start_index],
num_frames * sizeof(dst[i][dst_start_index]));
@ -51,10 +51,10 @@ void CopyFrames(const float* const* src,
void MoveFrames(const float* const* src,
size_t src_start_index,
size_t num_frames,
int num_channels,
size_t num_channels,
float* const* dst,
size_t dst_start_index) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
memmove(&dst[i][dst_start_index],
&src[i][src_start_index],
num_frames * sizeof(dst[i][dst_start_index]));
@ -64,8 +64,8 @@ void MoveFrames(const float* const* src,
void ZeroOut(float* const* buffer,
size_t starting_idx,
size_t num_frames,
int num_channels) {
for (int i = 0; i < num_channels; ++i) {
size_t num_channels) {
for (size_t i = 0; i < num_channels; ++i) {
memset(&buffer[i][starting_idx], 0,
num_frames * sizeof(buffer[i][starting_idx]));
}
@ -75,9 +75,9 @@ void ZeroOut(float* const* buffer,
// stored in |frames|.
void ApplyWindow(const float* window,
size_t num_frames,
int num_channels,
size_t num_channels,
float* const* frames) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
frames[i][j] = frames[i][j] * window[j];
}
@ -100,8 +100,8 @@ namespace webrtc {
Blocker::Blocker(size_t chunk_size,
size_t block_size,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
const float* window,
size_t shift_amount,
BlockerCallback* callback)
@ -166,8 +166,8 @@ Blocker::Blocker(size_t chunk_size,
// TODO(claguna): Look at using ring buffers to eliminate some copies.
void Blocker::ProcessChunk(const float* const* input,
size_t chunk_size,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output) {
RTC_CHECK_EQ(chunk_size, chunk_size_);
RTC_CHECK_EQ(num_input_channels, num_input_channels_);

View File

@ -26,8 +26,8 @@ class BlockerCallback {
virtual void ProcessBlock(const float* const* input,
size_t num_frames,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output) = 0;
};
@ -65,23 +65,23 @@ class Blocker {
public:
Blocker(size_t chunk_size,
size_t block_size,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
const float* window,
size_t shift_amount,
BlockerCallback* callback);
void ProcessChunk(const float* const* input,
size_t chunk_size,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output);
private:
const size_t chunk_size_;
const size_t block_size_;
const int num_input_channels_;
const int num_output_channels_;
const size_t num_input_channels_;
const size_t num_output_channels_;
// The number of frames of delay to add at the beginning of the first chunk.
const size_t initial_delay_;

View File

@ -20,10 +20,10 @@ class PlusThreeBlockerCallback : public webrtc::BlockerCallback {
public:
void ProcessBlock(const float* const* input,
size_t num_frames,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output) override {
for (int i = 0; i < num_output_channels; ++i) {
for (size_t i = 0; i < num_output_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
output[i][j] = input[i][j] + 3;
}
@ -36,10 +36,10 @@ class CopyBlockerCallback : public webrtc::BlockerCallback {
public:
void ProcessBlock(const float* const* input,
size_t num_frames,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output) override {
for (int i = 0; i < num_output_channels; ++i) {
for (size_t i = 0; i < num_output_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
output[i][j] = input[i][j];
}
@ -63,8 +63,8 @@ class BlockerTest : public ::testing::Test {
float* const* input_chunk,
float* const* output,
float* const* output_chunk,
int num_input_channels,
int num_output_channels) {
size_t num_input_channels,
size_t num_output_channels) {
size_t start = 0;
size_t end = chunk_size - 1;
while (end < num_frames) {
@ -83,9 +83,9 @@ class BlockerTest : public ::testing::Test {
void ValidateSignalEquality(const float* const* expected,
const float* const* actual,
int num_channels,
size_t num_channels,
size_t num_frames) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
EXPECT_FLOAT_EQ(expected[i][j], actual[i][j]);
}
@ -93,10 +93,10 @@ class BlockerTest : public ::testing::Test {
}
void ValidateInitialDelay(const float* const* output,
int num_channels,
size_t num_channels,
size_t num_frames,
size_t initial_delay) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
for (size_t j = 0; j < num_frames; ++j) {
if (j < initial_delay) {
EXPECT_FLOAT_EQ(output[i][j], 0.f);
@ -110,10 +110,10 @@ class BlockerTest : public ::testing::Test {
static void CopyTo(float* const* dst,
size_t start_index_dst,
size_t start_index_src,
int num_channels,
size_t num_channels,
size_t num_frames,
const float* const* src) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
memcpy(&dst[i][start_index_dst],
&src[i][start_index_src],
num_frames * sizeof(float));
@ -122,8 +122,8 @@ class BlockerTest : public ::testing::Test {
};
TEST_F(BlockerTest, TestBlockerMutuallyPrimeChunkandBlockSize) {
const int kNumInputChannels = 3;
const int kNumOutputChannels = 2;
const size_t kNumInputChannels = 3;
const size_t kNumOutputChannels = 2;
const size_t kNumFrames = 10;
const size_t kBlockSize = 4;
const size_t kChunkSize = 5;
@ -175,8 +175,8 @@ TEST_F(BlockerTest, TestBlockerMutuallyPrimeChunkandBlockSize) {
}
TEST_F(BlockerTest, TestBlockerMutuallyPrimeShiftAndBlockSize) {
const int kNumInputChannels = 3;
const int kNumOutputChannels = 2;
const size_t kNumInputChannels = 3;
const size_t kNumOutputChannels = 2;
const size_t kNumFrames = 12;
const size_t kBlockSize = 4;
const size_t kChunkSize = 6;
@ -228,8 +228,8 @@ TEST_F(BlockerTest, TestBlockerMutuallyPrimeShiftAndBlockSize) {
}
TEST_F(BlockerTest, TestBlockerNoOverlap) {
const int kNumInputChannels = 3;
const int kNumOutputChannels = 2;
const size_t kNumInputChannels = 3;
const size_t kNumOutputChannels = 2;
const size_t kNumFrames = 12;
const size_t kBlockSize = 4;
const size_t kChunkSize = 4;
@ -281,8 +281,8 @@ TEST_F(BlockerTest, TestBlockerNoOverlap) {
}
TEST_F(BlockerTest, InitialDelaysAreMinimum) {
const int kNumInputChannels = 3;
const int kNumOutputChannels = 2;
const size_t kNumInputChannels = 3;
const size_t kNumOutputChannels = 2;
const size_t kNumFrames = 1280;
const size_t kChunkSize[] =
{80, 80, 80, 80, 80, 80, 160, 160, 160, 160, 160, 160};
@ -294,7 +294,7 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) {
{48, 48, 48, 112, 112, 112, 96, 96, 96, 224, 224, 224};
float input[kNumInputChannels][kNumFrames];
for (int i = 0; i < kNumInputChannels; ++i) {
for (size_t i = 0; i < kNumInputChannels; ++i) {
for (size_t j = 0; j < kNumFrames; ++j) {
input[i][j] = i + 1;
}

View File

@ -13,7 +13,7 @@
namespace webrtc {
IFChannelBuffer::IFChannelBuffer(size_t num_frames,
int num_channels,
size_t num_channels,
size_t num_bands)
: ivalid_(true),
ibuf_(num_frames, num_channels, num_bands),
@ -47,7 +47,7 @@ void IFChannelBuffer::RefreshF() const {
assert(ivalid_);
const int16_t* const* int_channels = ibuf_.channels();
float* const* float_channels = fbuf_.channels();
for (int i = 0; i < ibuf_.num_channels(); ++i) {
for (size_t i = 0; i < ibuf_.num_channels(); ++i) {
for (size_t j = 0; j < ibuf_.num_frames(); ++j) {
float_channels[i][j] = int_channels[i][j];
}
@ -61,7 +61,7 @@ void IFChannelBuffer::RefreshI() const {
assert(fvalid_);
int16_t* const* int_channels = ibuf_.channels();
const float* const* float_channels = fbuf_.channels();
for (int i = 0; i < ibuf_.num_channels(); ++i) {
for (size_t i = 0; i < ibuf_.num_channels(); ++i) {
FloatS16ToS16(float_channels[i],
ibuf_.num_frames(),
int_channels[i]);

View File

@ -40,7 +40,7 @@ template <typename T>
class ChannelBuffer {
public:
ChannelBuffer(size_t num_frames,
int num_channels,
size_t num_channels,
size_t num_bands = 1)
: data_(new T[num_frames * num_channels]()),
channels_(new T*[num_channels * num_bands]),
@ -49,7 +49,7 @@ class ChannelBuffer {
num_frames_per_band_(num_frames / num_bands),
num_channels_(num_channels),
num_bands_(num_bands) {
for (int i = 0; i < num_channels_; ++i) {
for (size_t i = 0; i < num_channels_; ++i) {
for (size_t j = 0; j < num_bands_; ++j) {
channels_[j * num_channels_ + i] =
&data_[i * num_frames_ + j * num_frames_per_band_];
@ -90,12 +90,12 @@ class ChannelBuffer {
// 0 <= channel < |num_channels_|
// 0 <= band < |num_bands_|
// 0 <= sample < |num_frames_per_band_|
const T* const* bands(int channel) const {
const T* const* bands(size_t channel) const {
RTC_DCHECK_LT(channel, num_channels_);
RTC_DCHECK_GE(channel, 0);
RTC_DCHECK_GE(channel, 0u);
return &bands_[channel * num_bands_];
}
T* const* bands(int channel) {
T* const* bands(size_t channel) {
const ChannelBuffer<T>* t = this;
return const_cast<T* const*>(t->bands(channel));
}
@ -104,7 +104,7 @@ class ChannelBuffer {
// Returns |slice| for convenience.
const T* const* Slice(T** slice, size_t start_frame) const {
RTC_DCHECK_LT(start_frame, num_frames_);
for (int i = 0; i < num_channels_; ++i)
for (size_t i = 0; i < num_channels_; ++i)
slice[i] = &channels_[i][start_frame];
return slice;
}
@ -115,7 +115,7 @@ class ChannelBuffer {
size_t num_frames() const { return num_frames_; }
size_t num_frames_per_band() const { return num_frames_per_band_; }
int num_channels() const { return num_channels_; }
size_t num_channels() const { return num_channels_; }
size_t num_bands() const { return num_bands_; }
size_t size() const {return num_frames_ * num_channels_; }
@ -130,7 +130,7 @@ class ChannelBuffer {
rtc::scoped_ptr<T* []> bands_;
const size_t num_frames_;
const size_t num_frames_per_band_;
const int num_channels_;
const size_t num_channels_;
const size_t num_bands_;
};
@ -142,7 +142,7 @@ class ChannelBuffer {
// fbuf() until the next call to any of the other functions.
class IFChannelBuffer {
public:
IFChannelBuffer(size_t num_frames, int num_channels, size_t num_bands = 1);
IFChannelBuffer(size_t num_frames, size_t num_channels, size_t num_bands = 1);
ChannelBuffer<int16_t>* ibuf();
ChannelBuffer<float>* fbuf();
@ -151,7 +151,7 @@ class IFChannelBuffer {
size_t num_frames() const { return ibuf_.num_frames(); }
size_t num_frames_per_band() const { return ibuf_.num_frames_per_band(); }
int num_channels() const { return ibuf_.num_channels(); }
size_t num_channels() const { return ibuf_.num_channels(); }
size_t num_bands() const { return ibuf_.num_bands(); }
private:

View File

@ -87,11 +87,11 @@ void CopyAudioIfNeeded(const T* const* src,
template <typename T>
void Deinterleave(const T* interleaved,
size_t samples_per_channel,
int num_channels,
size_t num_channels,
T* const* deinterleaved) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
T* channel = deinterleaved[i];
int interleaved_idx = i;
size_t interleaved_idx = i;
for (size_t j = 0; j < samples_per_channel; ++j) {
channel[j] = interleaved[interleaved_idx];
interleaved_idx += num_channels;
@ -105,11 +105,11 @@ void Deinterleave(const T* interleaved,
template <typename T>
void Interleave(const T* const* deinterleaved,
size_t samples_per_channel,
int num_channels,
size_t num_channels,
T* interleaved) {
for (int i = 0; i < num_channels; ++i) {
for (size_t i = 0; i < num_channels; ++i) {
const T* channel = deinterleaved[i];
int interleaved_idx = i;
size_t interleaved_idx = i;
for (size_t j = 0; j < samples_per_channel; ++j) {
interleaved[interleaved_idx] = channel[j];
interleaved_idx += num_channels;

View File

@ -21,14 +21,14 @@ namespace webrtc {
void LappedTransform::BlockThunk::ProcessBlock(const float* const* input,
size_t num_frames,
int num_input_channels,
int num_output_channels,
size_t num_input_channels,
size_t num_output_channels,
float* const* output) {
RTC_CHECK_EQ(num_input_channels, parent_->num_in_channels_);
RTC_CHECK_EQ(num_output_channels, parent_->num_out_channels_);
RTC_CHECK_EQ(parent_->block_length_, num_frames);
for (int i = 0; i < num_input_channels; ++i) {
for (size_t i = 0; i < num_input_channels; ++i) {
memcpy(parent_->real_buf_.Row(i), input[i],
num_frames * sizeof(*input[0]));
parent_->fft_->Forward(parent_->real_buf_.Row(i),
@ -44,7 +44,7 @@ void LappedTransform::BlockThunk::ProcessBlock(const float* const* input,
num_output_channels,
parent_->cplx_post_.Array());
for (int i = 0; i < num_output_channels; ++i) {
for (size_t i = 0; i < num_output_channels; ++i) {
parent_->fft_->Inverse(parent_->cplx_post_.Row(i),
parent_->real_buf_.Row(i));
memcpy(output[i], parent_->real_buf_.Row(i),
@ -52,8 +52,8 @@ void LappedTransform::BlockThunk::ProcessBlock(const float* const* input,
}
}
LappedTransform::LappedTransform(int num_in_channels,
int num_out_channels,
LappedTransform::LappedTransform(size_t num_in_channels,
size_t num_out_channels,
size_t chunk_length,
const float* window,
size_t block_length,

View File

@ -35,8 +35,8 @@ class LappedTransform {
virtual ~Callback() {}
virtual void ProcessAudioBlock(const std::complex<float>* const* in_block,
int num_in_channels, size_t frames,
int num_out_channels,
size_t num_in_channels, size_t frames,
size_t num_out_channels,
std::complex<float>* const* out_block) = 0;
};
@ -46,8 +46,8 @@ class LappedTransform {
// |block_length| defines the length of a block, in samples.
// |shift_amount| is in samples. |callback| is the caller-owned audio
// processing function called for each block of the input chunk.
LappedTransform(int num_in_channels,
int num_out_channels,
LappedTransform(size_t num_in_channels,
size_t num_out_channels,
size_t chunk_length,
const float* window,
size_t block_length,
@ -75,7 +75,7 @@ class LappedTransform {
// in_chunk.
//
// Returns the same num_in_channels passed to the LappedTransform constructor.
int num_in_channels() const { return num_in_channels_; }
size_t num_in_channels() const { return num_in_channels_; }
// Get the number of output channels.
//
@ -84,7 +84,7 @@ class LappedTransform {
//
// Returns the same num_out_channels passed to the LappedTransform
// constructor.
int num_out_channels() const { return num_out_channels_; }
size_t num_out_channels() const { return num_out_channels_; }
private:
// Internal middleware callback, given to the blocker. Transforms each block
@ -93,16 +93,18 @@ class LappedTransform {
public:
explicit BlockThunk(LappedTransform* parent) : parent_(parent) {}
virtual void ProcessBlock(const float* const* input, size_t num_frames,
int num_input_channels, int num_output_channels,
virtual void ProcessBlock(const float* const* input,
size_t num_frames,
size_t num_input_channels,
size_t num_output_channels,
float* const* output);
private:
LappedTransform* const parent_;
} blocker_callback_;
const int num_in_channels_;
const int num_out_channels_;
const size_t num_in_channels_;
const size_t num_out_channels_;
const size_t block_length_;
const size_t chunk_length_;

View File

@ -25,12 +25,12 @@ class NoopCallback : public webrtc::LappedTransform::Callback {
NoopCallback() : block_num_(0) {}
virtual void ProcessAudioBlock(const complex<float>* const* in_block,
int in_channels,
size_t in_channels,
size_t frames,
int out_channels,
size_t out_channels,
complex<float>* const* out_block) {
RTC_CHECK_EQ(in_channels, out_channels);
for (int i = 0; i < out_channels; ++i) {
for (size_t i = 0; i < out_channels; ++i) {
memcpy(out_block[i], in_block[i], sizeof(**in_block) * frames);
}
++block_num_;
@ -49,9 +49,9 @@ class FftCheckerCallback : public webrtc::LappedTransform::Callback {
FftCheckerCallback() : block_num_(0) {}
virtual void ProcessAudioBlock(const complex<float>* const* in_block,
int in_channels,
size_t in_channels,
size_t frames,
int out_channels,
size_t out_channels,
complex<float>* const* out_block) {
RTC_CHECK_EQ(in_channels, out_channels);
@ -90,7 +90,7 @@ void SetFloatArray(float value, int rows, int cols, float* const* array) {
namespace webrtc {
TEST(LappedTransformTest, Windowless) {
const int kChannels = 3;
const size_t kChannels = 3;
const size_t kChunkLength = 512;
const size_t kBlockLength = 64;
const size_t kShiftAmount = 64;
@ -118,7 +118,7 @@ TEST(LappedTransformTest, Windowless) {
trans.ProcessChunk(in_chunk, out_chunk);
for (int i = 0; i < kChannels; ++i) {
for (size_t i = 0; i < kChannels; ++i) {
for (size_t j = 0; j < kChunkLength; ++j) {
ASSERT_NEAR(out_chunk[i][j], 2.0f, 1e-5f);
}

View File

@ -29,7 +29,7 @@ class PushResampler {
// Must be called whenever the parameters change. Free to be called at any
// time as it is a no-op if parameters have not changed since the last call.
int InitializeIfNeeded(int src_sample_rate_hz, int dst_sample_rate_hz,
int num_channels);
size_t num_channels);
// Returns the total number of samples provided in destination (e.g. 32 kHz,
// 2 channel audio gives 640 samples).
@ -40,7 +40,7 @@ class PushResampler {
rtc::scoped_ptr<PushSincResampler> sinc_resampler_right_;
int src_sample_rate_hz_;
int dst_sample_rate_hz_;
int num_channels_;
size_t num_channels_;
rtc::scoped_ptr<T[]> src_left_;
rtc::scoped_ptr<T[]> src_right_;
rtc::scoped_ptr<T[]> dst_left_;

View File

@ -28,14 +28,14 @@ class Resampler
public:
Resampler();
Resampler(int inFreq, int outFreq, int num_channels);
Resampler(int inFreq, int outFreq, size_t num_channels);
~Resampler();
// Reset all states
int Reset(int inFreq, int outFreq, int num_channels);
int Reset(int inFreq, int outFreq, size_t num_channels);
// Reset all states if any parameter has changed
int ResetIfNeeded(int inFreq, int outFreq, int num_channels);
int ResetIfNeeded(int inFreq, int outFreq, size_t num_channels);
// Resample samplesIn to samplesOut.
int Push(const int16_t* samplesIn, size_t lengthIn, int16_t* samplesOut,
@ -83,7 +83,7 @@ private:
int my_in_frequency_khz_;
int my_out_frequency_khz_;
ResamplerMode my_mode_;
int num_channels_;
size_t num_channels_;
// Extra instance for stereo
Resampler* slave_left_;

View File

@ -32,7 +32,7 @@ PushResampler<T>::~PushResampler() {
template <typename T>
int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
int dst_sample_rate_hz,
int num_channels) {
size_t num_channels) {
if (src_sample_rate_hz == src_sample_rate_hz_ &&
dst_sample_rate_hz == dst_sample_rate_hz_ &&
num_channels == num_channels_)
@ -68,10 +68,8 @@ int PushResampler<T>::InitializeIfNeeded(int src_sample_rate_hz,
template <typename T>
int PushResampler<T>::Resample(const T* src, size_t src_length, T* dst,
size_t dst_capacity) {
const size_t src_size_10ms =
static_cast<size_t>(src_sample_rate_hz_ * num_channels_ / 100);
const size_t dst_size_10ms =
static_cast<size_t>(dst_sample_rate_hz_ * num_channels_ / 100);
const size_t src_size_10ms = src_sample_rate_hz_ * num_channels_ / 100;
const size_t dst_size_10ms = dst_sample_rate_hz_ * num_channels_ / 100;
if (src_length != src_size_10ms || dst_capacity < dst_size_10ms)
return -1;

View File

@ -39,7 +39,7 @@ Resampler::Resampler()
slave_right_(nullptr) {
}
Resampler::Resampler(int inFreq, int outFreq, int num_channels)
Resampler::Resampler(int inFreq, int outFreq, size_t num_channels)
: Resampler() {
Reset(inFreq, outFreq, num_channels);
}
@ -76,7 +76,7 @@ Resampler::~Resampler()
}
}
int Resampler::ResetIfNeeded(int inFreq, int outFreq, int num_channels)
int Resampler::ResetIfNeeded(int inFreq, int outFreq, size_t num_channels)
{
int tmpInFreq_kHz = inFreq / 1000;
int tmpOutFreq_kHz = outFreq / 1000;
@ -91,7 +91,7 @@ int Resampler::ResetIfNeeded(int inFreq, int outFreq, int num_channels)
}
}
int Resampler::Reset(int inFreq, int outFreq, int num_channels)
int Resampler::Reset(int inFreq, int outFreq, size_t num_channels)
{
if (num_channels != 1 && num_channels != 2) {
return -1;

View File

@ -99,7 +99,7 @@ void WavReader::Close() {
}
WavWriter::WavWriter(const std::string& filename, int sample_rate,
int num_channels)
size_t num_channels)
: sample_rate_(sample_rate),
num_channels_(num_channels),
num_samples_(0),
@ -153,7 +153,7 @@ void WavWriter::Close() {
rtc_WavWriter* rtc_WavOpen(const char* filename,
int sample_rate,
int num_channels) {
size_t num_channels) {
return reinterpret_cast<rtc_WavWriter*>(
new webrtc::WavWriter(filename, sample_rate, num_channels));
}
@ -172,7 +172,7 @@ int rtc_WavSampleRate(const rtc_WavWriter* wf) {
return reinterpret_cast<const webrtc::WavWriter*>(wf)->sample_rate();
}
int rtc_WavNumChannels(const rtc_WavWriter* wf) {
size_t rtc_WavNumChannels(const rtc_WavWriter* wf) {
return reinterpret_cast<const webrtc::WavWriter*>(wf)->num_channels();
}

View File

@ -27,7 +27,7 @@ class WavFile {
virtual ~WavFile() {}
virtual int sample_rate() const = 0;
virtual int num_channels() const = 0;
virtual size_t num_channels() const = 0;
virtual size_t num_samples() const = 0;
// Returns a human-readable string containing the audio format.
@ -39,7 +39,7 @@ class WavFile {
class WavWriter final : public WavFile {
public:
// Open a new WAV file for writing.
WavWriter(const std::string& filename, int sample_rate, int num_channels);
WavWriter(const std::string& filename, int sample_rate, size_t num_channels);
// Close the WAV file, after writing its header.
~WavWriter();
@ -51,13 +51,13 @@ class WavWriter final : public WavFile {
void WriteSamples(const int16_t* samples, size_t num_samples);
int sample_rate() const override { return sample_rate_; }
int num_channels() const override { return num_channels_; }
size_t num_channels() const override { return num_channels_; }
size_t num_samples() const override { return num_samples_; }
private:
void Close();
const int sample_rate_;
const int num_channels_;
const size_t num_channels_;
size_t num_samples_; // Total number of samples written to file.
FILE* file_handle_; // Output file, owned by this class
@ -79,13 +79,13 @@ class WavReader final : public WavFile {
size_t ReadSamples(size_t num_samples, int16_t* samples);
int sample_rate() const override { return sample_rate_; }
int num_channels() const override { return num_channels_; }
size_t num_channels() const override { return num_channels_; }
size_t num_samples() const override { return num_samples_; }
private:
void Close();
int sample_rate_;
int num_channels_;
size_t num_channels_;
size_t num_samples_; // Total number of samples in the file.
size_t num_samples_remaining_;
FILE* file_handle_; // Input file, owned by this class.
@ -102,13 +102,13 @@ extern "C" {
typedef struct rtc_WavWriter rtc_WavWriter;
rtc_WavWriter* rtc_WavOpen(const char* filename,
int sample_rate,
int num_channels);
size_t num_channels);
void rtc_WavClose(rtc_WavWriter* wf);
void rtc_WavWriteSamples(rtc_WavWriter* wf,
const float* samples,
size_t num_samples);
int rtc_WavSampleRate(const rtc_WavWriter* wf);
int rtc_WavNumChannels(const rtc_WavWriter* wf);
size_t rtc_WavNumChannels(const rtc_WavWriter* wf);
size_t rtc_WavNumSamples(const rtc_WavWriter* wf);
#ifdef __cplusplus

View File

@ -30,7 +30,7 @@ TEST(WavWriterTest, CPP) {
{
WavWriter w(outfile, 14099, 1);
EXPECT_EQ(14099, w.sample_rate());
EXPECT_EQ(1, w.num_channels());
EXPECT_EQ(1u, w.num_channels());
EXPECT_EQ(0u, w.num_samples());
w.WriteSamples(kSamples, kNumSamples);
EXPECT_EQ(kNumSamples, w.num_samples());
@ -78,7 +78,7 @@ TEST(WavWriterTest, CPP) {
{
WavReader r(outfile);
EXPECT_EQ(14099, r.sample_rate());
EXPECT_EQ(1, r.num_channels());
EXPECT_EQ(1u, r.num_channels());
EXPECT_EQ(kNumSamples, r.num_samples());
static const float kTruncatedSamples[] = {0.0, 10.0, 32767.0};
float samples[kNumSamples];
@ -93,7 +93,7 @@ TEST(WavWriterTest, C) {
const std::string outfile = test::OutputPath() + "wavtest2.wav";
rtc_WavWriter* w = rtc_WavOpen(outfile.c_str(), 11904, 2);
EXPECT_EQ(11904, rtc_WavSampleRate(w));
EXPECT_EQ(2, rtc_WavNumChannels(w));
EXPECT_EQ(2u, rtc_WavNumChannels(w));
EXPECT_EQ(0u, rtc_WavNumSamples(w));
static const size_t kNumSamples = 4;
rtc_WavWriteSamples(w, &kSamples[0], 2);
@ -136,7 +136,7 @@ TEST(WavWriterTest, C) {
TEST(WavWriterTest, LargeFile) {
std::string outfile = test::OutputPath() + "wavtest3.wav";
static const int kSampleRate = 8000;
static const int kNumChannels = 2;
static const size_t kNumChannels = 2;
static const size_t kNumSamples = 3 * kSampleRate * kNumChannels;
float samples[kNumSamples];
for (size_t i = 0; i < kNumSamples; i += kNumChannels) {

View File

@ -59,7 +59,7 @@ static_assert(sizeof(WavHeader) == kWavHeaderSize, "no padding in header");
} // namespace
bool CheckWavParameters(int num_channels,
bool CheckWavParameters(size_t num_channels,
int sample_rate,
WavFormat format,
size_t bytes_per_sample,
@ -67,12 +67,11 @@ bool CheckWavParameters(int num_channels,
// num_channels, sample_rate, and bytes_per_sample must be positive, must fit
// in their respective fields, and their product must fit in the 32-bit
// ByteRate field.
if (num_channels <= 0 || sample_rate <= 0 || bytes_per_sample == 0)
if (num_channels == 0 || sample_rate <= 0 || bytes_per_sample == 0)
return false;
if (static_cast<uint64_t>(sample_rate) > std::numeric_limits<uint32_t>::max())
return false;
if (static_cast<uint64_t>(num_channels) >
std::numeric_limits<uint16_t>::max())
if (num_channels > std::numeric_limits<uint16_t>::max())
return false;
if (static_cast<uint64_t>(bytes_per_sample) * 8 >
std::numeric_limits<uint16_t>::max())
@ -136,17 +135,18 @@ static inline uint32_t RiffChunkSize(size_t bytes_in_payload) {
bytes_in_payload + kWavHeaderSize - sizeof(ChunkHeader));
}
static inline uint32_t ByteRate(int num_channels, int sample_rate,
static inline uint32_t ByteRate(size_t num_channels, int sample_rate,
size_t bytes_per_sample) {
return static_cast<uint32_t>(num_channels * sample_rate * bytes_per_sample);
}
static inline uint16_t BlockAlign(int num_channels, size_t bytes_per_sample) {
static inline uint16_t BlockAlign(size_t num_channels,
size_t bytes_per_sample) {
return static_cast<uint16_t>(num_channels * bytes_per_sample);
}
void WriteWavHeader(uint8_t* buf,
int num_channels,
size_t num_channels,
int sample_rate,
WavFormat format,
size_t bytes_per_sample,
@ -181,7 +181,7 @@ void WriteWavHeader(uint8_t* buf,
}
bool ReadWavHeader(ReadableWav* readable,
int* num_channels,
size_t* num_channels,
int* sample_rate,
WavFormat* format,
size_t* bytes_per_sample,

View File

@ -32,7 +32,7 @@ enum WavFormat {
};
// Return true if the given parameters will make a well-formed WAV header.
bool CheckWavParameters(int num_channels,
bool CheckWavParameters(size_t num_channels,
int sample_rate,
WavFormat format,
size_t bytes_per_sample,
@ -43,7 +43,7 @@ bool CheckWavParameters(int num_channels,
// channels and contain the specified total number of samples of the specified
// type. CHECKs the input parameters for validity.
void WriteWavHeader(uint8_t* buf,
int num_channels,
size_t num_channels,
int sample_rate,
WavFormat format,
size_t bytes_per_sample,
@ -53,7 +53,7 @@ void WriteWavHeader(uint8_t* buf,
// the provided output parameters. ReadableWav is used because the header can
// be variably sized. Returns false if the header is invalid.
bool ReadWavHeader(ReadableWav* readable,
int* num_channels,
size_t* num_channels,
int* sample_rate,
WavFormat* format,
size_t* bytes_per_sample,

View File

@ -91,7 +91,7 @@ TEST(WavHeaderTest, CheckWavParameters) {
}
TEST(WavHeaderTest, ReadWavHeaderWithErrors) {
int num_channels = 0;
size_t num_channels = 0;
int sample_rate = 0;
WavFormat format = kWavFormatPcm;
size_t bytes_per_sample = 0;
@ -268,7 +268,7 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) {
static_assert(sizeof(kExpectedBuf) == kSize, "buffer size");
EXPECT_EQ(0, memcmp(kExpectedBuf, buf, kSize));
int num_channels = 0;
size_t num_channels = 0;
int sample_rate = 0;
WavFormat format = kWavFormatPcm;
size_t bytes_per_sample = 0;
@ -277,7 +277,7 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) {
EXPECT_TRUE(
ReadWavHeader(&r, &num_channels, &sample_rate, &format,
&bytes_per_sample, &num_samples));
EXPECT_EQ(17, num_channels);
EXPECT_EQ(17u, num_channels);
EXPECT_EQ(12345, sample_rate);
EXPECT_EQ(kWavFormatALaw, format);
EXPECT_EQ(1u, bytes_per_sample);
@ -304,7 +304,7 @@ TEST(WavHeaderTest, ReadAtypicalWavHeader) {
0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689
};
int num_channels = 0;
size_t num_channels = 0;
int sample_rate = 0;
WavFormat format = kWavFormatPcm;
size_t bytes_per_sample = 0;
@ -313,7 +313,7 @@ TEST(WavHeaderTest, ReadAtypicalWavHeader) {
EXPECT_TRUE(
ReadWavHeader(&r, &num_channels, &sample_rate, &format,
&bytes_per_sample, &num_samples));
EXPECT_EQ(17, num_channels);
EXPECT_EQ(17u, num_channels);
EXPECT_EQ(12345, sample_rate);
EXPECT_EQ(kWavFormatALaw, format);
EXPECT_EQ(1u, bytes_per_sample);

View File

@ -291,7 +291,7 @@ struct CodecInst {
char plname[RTP_PAYLOAD_NAME_SIZE];
int plfreq;
int pacsize;
int channels;
size_t channels;
int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
bool operator==(const CodecInst& other) const {

View File

@ -292,7 +292,9 @@ int ACMCodecDB::CodecId(const CodecInst& codec_inst) {
codec_inst.channels));
}
int ACMCodecDB::CodecId(const char* payload_name, int frequency, int channels) {
int ACMCodecDB::CodecId(const char* payload_name,
int frequency,
size_t channels) {
for (const CodecInst& ci : RentACodec::Database()) {
bool name_match = false;
bool frequency_match = false;

View File

@ -48,7 +48,7 @@ class ACMCodecDB {
int num_packet_sizes;
int packet_sizes_samples[kMaxNumPacketSize];
int basic_block_samples;
int channel_support;
size_t channel_support;
};
// Returns codec id from database, given the information received in the input
@ -60,7 +60,7 @@ class ACMCodecDB {
// codec id if successful, otherwise < 0.
static int CodecNumber(const CodecInst& codec_inst);
static int CodecId(const CodecInst& codec_inst);
static int CodecId(const char* payload_name, int frequency, int channels);
static int CodecId(const char* payload_name, int frequency, size_t channels);
static int ReceiverCodecNumber(const CodecInst& codec_inst);
// Databases with information about the supported codecs

View File

@ -55,7 +55,7 @@ bool ModifyAndUseThisCodec(CodecInst* codec_param) {
// G.722 = 94
bool RemapPltypeAndUseThisCodec(const char* plname,
int plfreq,
int channels,
size_t channels,
int* pltype) {
if (channels != 1)
return false; // Don't use non-mono codecs.

View File

@ -213,7 +213,7 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
enum NetEqOutputType type;
size_t samples_per_channel;
int num_channels;
size_t num_channels;
// Accessing members, take the lock.
CriticalSectionScoped lock(crit_sect_.get());
@ -301,7 +301,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
int32_t AcmReceiver::AddCodec(int acm_codec_id,
uint8_t payload_type,
int channels,
size_t channels,
int sample_rate_hz,
AudioDecoder* audio_decoder,
const std::string& name) {

View File

@ -44,7 +44,7 @@ class AcmReceiver {
uint8_t payload_type;
// This field is meaningful for codecs where both mono and
// stereo versions are registered under the same ID.
int channels;
size_t channels;
int sample_rate_hz;
};
@ -116,7 +116,7 @@ class AcmReceiver {
//
int AddCodec(int acm_codec_id,
uint8_t payload_type,
int channels,
size_t channels,
int sample_rate_hz,
AudioDecoder* audio_decoder,
const std::string& name);

View File

@ -28,10 +28,10 @@ ACMResampler::~ACMResampler() {
int ACMResampler::Resample10Msec(const int16_t* in_audio,
int in_freq_hz,
int out_freq_hz,
int num_audio_channels,
size_t num_audio_channels,
size_t out_capacity_samples,
int16_t* out_audio) {
size_t in_length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100);
size_t in_length = in_freq_hz * num_audio_channels / 100;
if (in_freq_hz == out_freq_hz) {
if (out_capacity_samples < in_length) {
assert(false);
@ -56,7 +56,7 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
return -1;
}
return out_length / num_audio_channels;
return static_cast<int>(out_length / num_audio_channels);
}
} // namespace acm2

View File

@ -25,7 +25,7 @@ class ACMResampler {
int Resample10Msec(const int16_t* in_audio,
int in_freq_hz,
int out_freq_hz,
int num_audio_channels,
size_t num_audio_channels,
size_t out_capacity_samples,
int16_t* out_audio);

View File

@ -56,7 +56,7 @@ int AudioCodingModule::Codec(int list_id, CodecInst* codec) {
int AudioCodingModule::Codec(const char* payload_name,
CodecInst* codec,
int sampling_freq_hz,
int channels) {
size_t channels) {
rtc::Optional<CodecInst> ci = acm2::RentACodec::CodecInstByParams(
payload_name, sampling_freq_hz, channels);
if (ci) {
@ -76,7 +76,7 @@ int AudioCodingModule::Codec(const char* payload_name,
int AudioCodingModule::Codec(const char* payload_name,
int sampling_freq_hz,
int channels) {
size_t channels) {
rtc::Optional<acm2::RentACodec::CodecId> ci =
acm2::RentACodec::CodecIdByParams(payload_name, sampling_freq_hz,
channels);

View File

@ -324,7 +324,7 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
}
// Check whether we need an up-mix or down-mix?
const int current_num_channels =
const size_t current_num_channels =
rent_a_codec_.GetEncoderStack()->NumChannels();
const bool same_num_channels =
ptr_frame->num_channels_ == current_num_channels;
@ -589,7 +589,7 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
CriticalSectionScoped lock(acm_crit_sect_.get());
RTC_DCHECK(receiver_initialized_);
if (codec.channels > 2 || codec.channels < 0) {
if (codec.channels > 2) {
LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
return -1;
}

View File

@ -189,7 +189,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
uint32_t input_timestamp;
const int16_t* audio;
size_t length_per_channel;
uint8_t audio_channel;
size_t audio_channel;
// If a re-mix is required (up or down), this buffer will store a re-mixed
// version of the input.
int16_t buffer[WEBRTC_10MS_PCM_AUDIO];

View File

@ -300,7 +300,7 @@ TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
EXPECT_EQ(0, acm_->PlayoutData10Ms(kSampleRateHz, &audio_frame));
EXPECT_EQ(id_, audio_frame.id_);
EXPECT_EQ(0u, audio_frame.timestamp_);
EXPECT_GT(audio_frame.num_channels_, 0);
EXPECT_GT(audio_frame.num_channels_, 0u);
EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100),
audio_frame.samples_per_channel_);
EXPECT_EQ(kSampleRateHz, audio_frame.sample_rate_hz_);

View File

@ -11,6 +11,7 @@
#include "webrtc/modules/audio_coding/acm2/codec_manager.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -25,8 +26,8 @@ int IsValidSendCodec(const CodecInst& send_codec) {
int dummy_id = 0;
if ((send_codec.channels != 1) && (send_codec.channels != 2)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
"Wrong number of channels (%d, only mono and stereo are "
"supported)",
"Wrong number of channels (%" PRIuS ", only mono and stereo "
"are supported)",
send_codec.channels);
return -1;
}
@ -48,7 +49,7 @@ int IsValidSendCodec(const CodecInst& send_codec) {
if (!RentACodec::IsSupportedNumChannels(*maybe_codec_id, send_codec.channels)
.value_or(false)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
"%d number of channels not supportedn for %s.",
"%" PRIuS " number of channels not supportedn for %s.",
send_codec.channels, send_codec.plname);
return -1;
}

View File

@ -45,7 +45,7 @@ namespace acm2 {
rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams(
const char* payload_name,
int sampling_freq_hz,
int channels) {
size_t channels) {
return CodecIdFromIndex(
ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels));
}
@ -63,7 +63,7 @@ rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByInst(
rtc::Optional<CodecInst> RentACodec::CodecInstByParams(const char* payload_name,
int sampling_freq_hz,
int channels) {
size_t channels) {
rtc::Optional<CodecId> codec_id =
CodecIdByParams(payload_name, sampling_freq_hz, channels);
if (!codec_id)
@ -83,7 +83,7 @@ bool RentACodec::IsCodecValid(const CodecInst& codec_inst) {
}
rtc::Optional<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id,
int num_channels) {
size_t num_channels) {
auto i = CodecIndexFromId(codec_id);
return i ? rtc::Optional<bool>(
ACMCodecDB::codec_settings_[*i].channel_support >=
@ -98,7 +98,7 @@ rtc::ArrayView<const CodecInst> RentACodec::Database() {
rtc::Optional<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId(
CodecId codec_id,
int num_channels) {
size_t num_channels) {
rtc::Optional<int> i = CodecIndexFromId(codec_id);
if (!i)
return rtc::Optional<NetEqDecoder>();

View File

@ -162,12 +162,12 @@ class RentACodec {
static rtc::Optional<CodecId> CodecIdByParams(const char* payload_name,
int sampling_freq_hz,
int channels);
size_t channels);
static rtc::Optional<CodecInst> CodecInstById(CodecId codec_id);
static rtc::Optional<CodecId> CodecIdByInst(const CodecInst& codec_inst);
static rtc::Optional<CodecInst> CodecInstByParams(const char* payload_name,
int sampling_freq_hz,
int channels);
size_t channels);
static bool IsCodecValid(const CodecInst& codec_inst);
static inline bool IsPayloadTypeValid(int payload_type) {
@ -177,10 +177,11 @@ class RentACodec {
static rtc::ArrayView<const CodecInst> Database();
static rtc::Optional<bool> IsSupportedNumChannels(CodecId codec_id,
int num_channels);
size_t num_channels);
static rtc::Optional<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id,
int num_channels);
static rtc::Optional<NetEqDecoder> NetEqDecoderFromCodecId(
CodecId codec_id,
size_t num_channels);
// Parse codec_inst and extract payload types. If the given CodecInst was for
// the wrong sort of codec, return kSkip; otherwise, if the rate was illegal,

View File

@ -61,7 +61,7 @@ class AudioEncoder {
// Returns the input sample rate in Hz and the number of input channels.
// These are constants set at instantiation time.
virtual int SampleRateHz() const = 0;
virtual int NumChannels() const = 0;
virtual size_t NumChannels() const = 0;
// Returns the rate at which the RTP timestamps are updated. The default
// implementation returns SampleRateHz().

View File

@ -75,7 +75,7 @@ int AudioEncoderCng::SampleRateHz() const {
return speech_encoder_->SampleRateHz();
}
int AudioEncoderCng::NumChannels() const {
size_t AudioEncoderCng::NumChannels() const {
return 1;
}

View File

@ -32,7 +32,7 @@ class AudioEncoderCng final : public AudioEncoder {
struct Config {
bool IsOk() const;
int num_channels = 1;
size_t num_channels = 1;
int payload_type = 13;
// Caller keeps ownership of the AudioEncoder object.
AudioEncoder* speech_encoder = nullptr;
@ -51,7 +51,7 @@ class AudioEncoderCng final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
int RtpTimestampRateHz() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;

View File

@ -20,15 +20,6 @@ namespace webrtc {
namespace {
int16_t NumSamplesPerFrame(int num_channels,
int frame_size_ms,
int sample_rate_hz) {
int samples_per_frame = num_channels * frame_size_ms * sample_rate_hz / 1000;
RTC_CHECK_LE(samples_per_frame, std::numeric_limits<int16_t>::max())
<< "Frame size too large.";
return static_cast<int16_t>(samples_per_frame);
}
template <typename T>
typename T::Config CreateConfig(const CodecInst& codec_inst) {
typename T::Config config;
@ -50,9 +41,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz)
payload_type_(config.payload_type),
num_10ms_frames_per_packet_(
static_cast<size_t>(config.frame_size_ms / 10)),
full_frame_samples_(NumSamplesPerFrame(config.num_channels,
config.frame_size_ms,
sample_rate_hz_)),
full_frame_samples_(
config.num_channels * config.frame_size_ms * sample_rate_hz / 1000),
first_timestamp_in_buffer_(0) {
RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
@ -70,7 +60,7 @@ int AudioEncoderPcm::SampleRateHz() const {
return sample_rate_hz_;
}
int AudioEncoderPcm::NumChannels() const {
size_t AudioEncoderPcm::NumChannels() const {
return num_channels_;
}

View File

@ -25,7 +25,7 @@ class AudioEncoderPcm : public AudioEncoder {
bool IsOk() const;
int frame_size_ms;
int num_channels;
size_t num_channels;
int payload_type;
protected:
@ -37,7 +37,7 @@ class AudioEncoderPcm : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;
@ -58,7 +58,7 @@ class AudioEncoderPcm : public AudioEncoder {
private:
const int sample_rate_hz_;
const int num_channels_;
const size_t num_channels_;
const int payload_type_;
const size_t num_10ms_frames_per_packet_;
const size_t full_frame_samples_;

View File

@ -48,7 +48,7 @@ AudioEncoderG722::AudioEncoderG722(const Config& config)
RTC_CHECK(config.IsOk());
const size_t samples_per_channel =
kSampleRateHz / 100 * num_10ms_frames_per_packet_;
for (int i = 0; i < num_channels_; ++i) {
for (size_t i = 0; i < num_channels_; ++i) {
encoders_[i].speech_buffer.reset(new int16_t[samples_per_channel]);
encoders_[i].encoded_buffer.SetSize(samples_per_channel / 2);
}
@ -68,7 +68,7 @@ int AudioEncoderG722::SampleRateHz() const {
return kSampleRateHz;
}
int AudioEncoderG722::NumChannels() const {
size_t AudioEncoderG722::NumChannels() const {
return num_channels_;
}
@ -88,7 +88,7 @@ size_t AudioEncoderG722::Max10MsFramesInAPacket() const {
int AudioEncoderG722::GetTargetBitrate() const {
// 4 bits/sample, 16000 samples/s/channel.
return 64000 * NumChannels();
return static_cast<int>(64000 * NumChannels());
}
AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
@ -104,7 +104,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
// Deinterleave samples and save them in each channel's buffer.
const size_t start = kSampleRateHz / 100 * num_10ms_frames_buffered_;
for (size_t i = 0; i < kSampleRateHz / 100; ++i)
for (int j = 0; j < num_channels_; ++j)
for (size_t j = 0; j < num_channels_; ++j)
encoders_[j].speech_buffer[start + i] = audio[i * num_channels_ + j];
// If we don't yet have enough samples for a packet, we're done for now.
@ -116,7 +116,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
RTC_CHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
num_10ms_frames_buffered_ = 0;
const size_t samples_per_channel = SamplesPerChannel();
for (int i = 0; i < num_channels_; ++i) {
for (size_t i = 0; i < num_channels_; ++i) {
const size_t encoded = WebRtcG722_Encode(
encoders_[i].encoder, encoders_[i].speech_buffer.get(),
samples_per_channel, encoders_[i].encoded_buffer.data());
@ -127,12 +127,12 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
// channel and the interleaved stream encodes two samples per byte, most
// significant half first.
for (size_t i = 0; i < samples_per_channel / 2; ++i) {
for (int j = 0; j < num_channels_; ++j) {
for (size_t j = 0; j < num_channels_; ++j) {
uint8_t two_samples = encoders_[j].encoded_buffer.data()[i];
interleave_buffer_.data()[j] = two_samples >> 4;
interleave_buffer_.data()[num_channels_ + j] = two_samples & 0xf;
}
for (int j = 0; j < num_channels_; ++j)
for (size_t j = 0; j < num_channels_; ++j)
encoded[i * num_channels_ + j] = interleave_buffer_.data()[2 * j] << 4 |
interleave_buffer_.data()[2 * j + 1];
}
@ -145,7 +145,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
void AudioEncoderG722::Reset() {
num_10ms_frames_buffered_ = 0;
for (int i = 0; i < num_channels_; ++i)
for (size_t i = 0; i < num_channels_; ++i)
RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder));
}

View File

@ -27,7 +27,7 @@ class AudioEncoderG722 final : public AudioEncoder {
int payload_type = 9;
int frame_size_ms = 20;
int num_channels = 1;
size_t num_channels = 1;
};
explicit AudioEncoderG722(const Config& config);
@ -36,7 +36,7 @@ class AudioEncoderG722 final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
int RtpTimestampRateHz() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
@ -59,7 +59,7 @@ class AudioEncoderG722 final : public AudioEncoder {
size_t SamplesPerChannel() const;
const int num_channels_;
const size_t num_channels_;
const int payload_type_;
const size_t num_10ms_frames_per_packet_;
size_t num_10ms_frames_buffered_;

View File

@ -64,7 +64,7 @@ int AudioEncoderIlbc::SampleRateHz() const {
return kSampleRateHz;
}
int AudioEncoderIlbc::NumChannels() const {
size_t AudioEncoderIlbc::NumChannels() const {
return 1;
}

View File

@ -36,7 +36,7 @@ class AudioEncoderIlbc final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;

View File

@ -56,7 +56,7 @@ class AudioEncoderIsacT final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;

View File

@ -88,7 +88,7 @@ int AudioEncoderIsacT<T>::SampleRateHz() const {
}
template <typename T>
int AudioEncoderIsacT<T>::NumChannels() const {
size_t AudioEncoderIsacT<T>::NumChannels() const {
return 1;
}

View File

@ -24,7 +24,7 @@ class MockAudioEncoder final : public AudioEncoder {
MOCK_METHOD1(Mark, void(std::string desc));
MOCK_CONST_METHOD0(MaxEncodedBytes, size_t());
MOCK_CONST_METHOD0(SampleRateHz, int());
MOCK_CONST_METHOD0(NumChannels, int());
MOCK_CONST_METHOD0(NumChannels, size_t());
MOCK_CONST_METHOD0(RtpTimestampRateHz, int());
MOCK_CONST_METHOD0(Num10MsFramesInNextPacket, size_t());
MOCK_CONST_METHOD0(Max10MsFramesInAPacket, size_t());

View File

@ -17,7 +17,7 @@ namespace webrtc {
AudioDecoderOpus::AudioDecoderOpus(size_t num_channels)
: channels_(num_channels) {
RTC_DCHECK(num_channels == 1 || num_channels == 2);
WebRtcOpus_DecoderCreate(&dec_state_, static_cast<int>(channels_));
WebRtcOpus_DecoderCreate(&dec_state_, channels_);
WebRtcOpus_DecoderInit(dec_state_);
}

View File

@ -114,7 +114,7 @@ int AudioEncoderOpus::SampleRateHz() const {
return kSampleRateHz;
}
int AudioEncoderOpus::NumChannels() const {
size_t AudioEncoderOpus::NumChannels() const {
return config_.num_channels;
}
@ -147,8 +147,7 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
Num10msFramesPerPacket() * SamplesPer10msFrame());
int status = WebRtcOpus_Encode(
inst_, &input_buffer_[0],
rtc::CheckedDivExact(input_buffer_.size(),
static_cast<size_t>(config_.num_channels)),
rtc::CheckedDivExact(input_buffer_.size(), config_.num_channels),
rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded);
RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
input_buffer_.clear();

View File

@ -31,7 +31,7 @@ class AudioEncoderOpus final : public AudioEncoder {
struct Config {
bool IsOk() const;
int frame_size_ms = 20;
int num_channels = 1;
size_t num_channels = 1;
int payload_type = 120;
ApplicationMode application = kVoip;
int bitrate_bps = 64000;
@ -56,7 +56,7 @@ class AudioEncoderOpus final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;

View File

@ -9,6 +9,7 @@
*/
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -21,7 +22,7 @@ using ::testing::TestWithParam;
namespace webrtc {
// Define coding parameter as <channels, bit_rate, filename, extension>.
typedef tuple<int, int, string, string> coding_param;
typedef tuple<size_t, int, string, string> coding_param;
typedef struct mode mode;
struct mode {
@ -47,7 +48,7 @@ class OpusFecTest : public TestWithParam<coding_param> {
int sampling_khz_;
size_t block_length_sample_;
int channels_;
size_t channels_;
int bit_rate_;
size_t data_pointer_;
@ -68,7 +69,7 @@ class OpusFecTest : public TestWithParam<coding_param> {
void OpusFecTest::SetUp() {
channels_ = get<0>(GetParam());
bit_rate_ = get<1>(GetParam());
printf("Coding %d channel signal at %d bps.\n", channels_, bit_rate_);
printf("Coding %" PRIuS " channel signal at %d bps.\n", channels_, bit_rate_);
in_filename_ = test::ResourcePath(get<2>(GetParam()), get<3>(GetParam()));

View File

@ -17,7 +17,7 @@
struct WebRtcOpusEncInst {
OpusEncoder* encoder;
int channels;
size_t channels;
int in_dtx_mode;
// When Opus is in DTX mode, we use |zero_counts| to count consecutive zeros
// to break long zero segment so as to prevent DTX from going wrong. We use
@ -30,7 +30,7 @@ struct WebRtcOpusEncInst {
struct WebRtcOpusDecInst {
OpusDecoder* decoder;
int prev_decoded_samples;
int channels;
size_t channels;
int in_dtx_mode;
};

View File

@ -42,7 +42,7 @@ enum {
};
int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
int32_t channels,
size_t channels,
int32_t application) {
int opus_app;
if (!inst)
@ -67,7 +67,7 @@ int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
assert(state->zero_counts);
int error;
state->encoder = opus_encoder_create(48000, channels, opus_app,
state->encoder = opus_encoder_create(48000, (int)channels, opus_app,
&error);
if (error != OPUS_OK || !state->encoder) {
WebRtcOpus_EncoderFree(state);
@ -99,7 +99,7 @@ int WebRtcOpus_Encode(OpusEncInst* inst,
uint8_t* encoded) {
int res;
size_t i;
int c;
size_t c;
int16_t buffer[2 * 48 * kWebRtcOpusMaxEncodeFrameSizeMs];
@ -107,7 +107,7 @@ int WebRtcOpus_Encode(OpusEncInst* inst,
return -1;
}
const int channels = inst->channels;
const size_t channels = inst->channels;
int use_buffer = 0;
// Break long consecutive zeros by forcing a "1" every |kZeroBreakCount|
@ -248,7 +248,7 @@ int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity) {
}
}
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels) {
int error;
OpusDecInst* state;
@ -260,7 +260,7 @@ int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
}
/* Create new memory, always at 48000 Hz. */
state->decoder = opus_decoder_create(48000, channels, &error);
state->decoder = opus_decoder_create(48000, (int)channels, &error);
if (error == OPUS_OK && state->decoder != NULL) {
/* Creation of memory all ok. */
state->channels = channels;
@ -289,7 +289,7 @@ int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst) {
}
}
int WebRtcOpus_DecoderChannels(OpusDecInst* inst) {
size_t WebRtcOpus_DecoderChannels(OpusDecInst* inst) {
return inst->channels;
}

View File

@ -43,7 +43,7 @@ typedef struct WebRtcOpusDecInst OpusDecInst;
* -1 - Error
*/
int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
int32_t channels,
size_t channels,
int32_t application);
int16_t WebRtcOpus_EncoderFree(OpusEncInst* inst);
@ -195,7 +195,7 @@ int16_t WebRtcOpus_DisableDtx(OpusEncInst* inst);
*/
int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity);
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels);
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels);
int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst);
/****************************************************************************
@ -203,7 +203,7 @@ int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst);
*
* This function returns the number of channels created for Opus decoder.
*/
int WebRtcOpus_DecoderChannels(OpusDecInst* inst);
size_t WebRtcOpus_DecoderChannels(OpusDecInst* inst);
/****************************************************************************
* WebRtcOpus_DecoderInit(...)

View File

@ -42,7 +42,9 @@ class OpusTest : public TestWithParam<::testing::tuple<int, int>> {
// After preparation, |speech_data_.GetNextBlock()| returns a pointer to a
// block of |block_length_ms| milliseconds. The data is looped every
// |loop_length_ms| milliseconds.
void PrepareSpeechData(int channel, int block_length_ms, int loop_length_ms);
void PrepareSpeechData(size_t channel,
int block_length_ms,
int loop_length_ms);
int EncodeDecode(WebRtcOpusEncInst* encoder,
rtc::ArrayView<const int16_t> input_audio,
@ -53,7 +55,7 @@ class OpusTest : public TestWithParam<::testing::tuple<int, int>> {
void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder,
opus_int32 expect, int32_t set);
void CheckAudioBounded(const int16_t* audio, size_t samples, int channels,
void CheckAudioBounded(const int16_t* audio, size_t samples, size_t channels,
uint16_t bound) const;
WebRtcOpusEncInst* opus_encoder_;
@ -62,7 +64,7 @@ class OpusTest : public TestWithParam<::testing::tuple<int, int>> {
AudioLoop speech_data_;
uint8_t bitstream_[kMaxBytes];
size_t encoded_bytes_;
int channels_;
size_t channels_;
int application_;
};
@ -70,11 +72,11 @@ OpusTest::OpusTest()
: opus_encoder_(NULL),
opus_decoder_(NULL),
encoded_bytes_(0),
channels_(::testing::get<0>(GetParam())),
channels_(static_cast<size_t>(::testing::get<0>(GetParam()))),
application_(::testing::get<1>(GetParam())) {
}
void OpusTest::PrepareSpeechData(int channel, int block_length_ms,
void OpusTest::PrepareSpeechData(size_t channel, int block_length_ms,
int loop_length_ms) {
const std::string file_name =
webrtc::test::ResourcePath((channel == 1) ?
@ -99,9 +101,9 @@ void OpusTest::SetMaxPlaybackRate(WebRtcOpusEncInst* encoder,
}
void OpusTest::CheckAudioBounded(const int16_t* audio, size_t samples,
int channels, uint16_t bound) const {
size_t channels, uint16_t bound) const {
for (size_t i = 0; i < samples; ++i) {
for (int c = 0; c < channels; ++c) {
for (size_t c = 0; c < channels; ++c) {
ASSERT_GE(audio[i * channels + c], -bound);
ASSERT_LE(audio[i * channels + c], bound);
}
@ -115,7 +117,7 @@ int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder,
int16_t* audio_type) {
int encoded_bytes_int = WebRtcOpus_Encode(
encoder, input_audio.data(),
rtc::CheckedDivExact(input_audio.size(), static_cast<size_t>(channels_)),
rtc::CheckedDivExact(input_audio.size(), channels_),
kMaxBytes, bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
encoded_bytes_ = static_cast<size_t>(encoded_bytes_int);
@ -588,8 +590,7 @@ TEST_P(OpusTest, OpusDurationEstimation) {
auto speech_block = speech_data_.GetNextBlock();
int encoded_bytes_int = WebRtcOpus_Encode(
opus_encoder_, speech_block.data(),
rtc::CheckedDivExact(speech_block.size(),
2 * static_cast<size_t>(channels_)),
rtc::CheckedDivExact(speech_block.size(), 2 * channels_),
kMaxBytes, bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
EXPECT_EQ(kOpus10msFrameSamples,
@ -601,7 +602,7 @@ TEST_P(OpusTest, OpusDurationEstimation) {
speech_block = speech_data_.GetNextBlock();
encoded_bytes_int = WebRtcOpus_Encode(
opus_encoder_, speech_block.data(),
rtc::CheckedDivExact(speech_block.size(), static_cast<size_t>(channels_)),
rtc::CheckedDivExact(speech_block.size(), channels_),
kMaxBytes, bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
EXPECT_EQ(kOpus20msFrameSamples,
@ -643,8 +644,7 @@ TEST_P(OpusTest, OpusDecodeRepacketized) {
auto speech_block = speech_data_.GetNextBlock();
encoded_bytes_ =
WebRtcOpus_Encode(opus_encoder_, speech_block.data(),
rtc::CheckedDivExact(speech_block.size(),
static_cast<size_t>(channels_)),
rtc::CheckedDivExact(speech_block.size(), channels_),
kMaxBytes, bitstream_);
EXPECT_EQ(OPUS_OK, opus_repacketizer_cat(rp, bitstream_, encoded_bytes_));
}

View File

@ -32,7 +32,7 @@ int AudioEncoderCopyRed::SampleRateHz() const {
return speech_encoder_->SampleRateHz();
}
int AudioEncoderCopyRed::NumChannels() const {
size_t AudioEncoderCopyRed::NumChannels() const {
return speech_encoder_->NumChannels();
}

View File

@ -38,7 +38,7 @@ class AudioEncoderCopyRed final : public AudioEncoder {
size_t MaxEncodedBytes() const override;
int SampleRateHz() const override;
int NumChannels() const override;
size_t NumChannels() const override;
int RtpTimestampRateHz() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;

View File

@ -42,7 +42,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test {
config.speech_encoder = &mock_encoder_;
red_.reset(new AudioEncoderCopyRed(config));
memset(audio_, 0, sizeof(audio_));
EXPECT_CALL(mock_encoder_, NumChannels()).WillRepeatedly(Return(1));
EXPECT_CALL(mock_encoder_, NumChannels()).WillRepeatedly(Return(1U));
EXPECT_CALL(mock_encoder_, SampleRateHz())
.WillRepeatedly(Return(sample_rate_hz_));
EXPECT_CALL(mock_encoder_, MaxEncodedBytes())
@ -110,8 +110,8 @@ TEST_F(AudioEncoderCopyRedTest, CheckSampleRatePropagation) {
}
TEST_F(AudioEncoderCopyRedTest, CheckNumChannelsPropagation) {
EXPECT_CALL(mock_encoder_, NumChannels()).WillOnce(Return(17));
EXPECT_EQ(17, red_->NumChannels());
EXPECT_CALL(mock_encoder_, NumChannels()).WillOnce(Return(17U));
EXPECT_EQ(17U, red_->NumChannels());
}
TEST_F(AudioEncoderCopyRedTest, CheckFrameSizePropagation) {

View File

@ -11,6 +11,7 @@
#include "webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/test/testsupport/fileutils.h"
using ::std::tr1::get;
@ -99,7 +100,7 @@ void AudioCodecSpeedTest::EncodeDecode(size_t audio_duration_sec) {
size_t time_now_ms = 0;
float time_ms;
printf("Coding %d kHz-sampled %d-channel audio at %d bps ...\n",
printf("Coding %d kHz-sampled %" PRIuS "-channel audio at %d bps ...\n",
input_sampling_khz_, channels_, bit_rate_);
while (time_now_ms < audio_duration_sec * 1000) {

View File

@ -20,7 +20,8 @@ namespace webrtc {
// Define coding parameter as
// <channels, bit_rate, file_name, extension, if_save_output>.
typedef std::tr1::tuple<int, int, std::string, std::string, bool> coding_param;
typedef std::tr1::tuple<size_t, int, std::string, std::string, bool>
coding_param;
class AudioCodecSpeedTest : public testing::TestWithParam<coding_param> {
protected:
@ -74,7 +75,7 @@ class AudioCodecSpeedTest : public testing::TestWithParam<coding_param> {
float decoding_time_ms_;
FILE* out_file_;
int channels_;
size_t channels_;
// Bit rate is in bit-per-second.
int bit_rate_;

View File

@ -134,7 +134,7 @@ class AudioCodingModule {
// 0 if succeeded.
//
static int Codec(const char* payload_name, CodecInst* codec,
int sampling_freq_hz, int channels);
int sampling_freq_hz, size_t channels);
///////////////////////////////////////////////////////////////////////////
// int32_t Codec()
@ -153,7 +153,7 @@ class AudioCodingModule {
// -1 if the codec is not found.
//
static int Codec(const char* payload_name, int sampling_freq_hz,
int channels);
size_t channels);
///////////////////////////////////////////////////////////////////////////
// bool IsCodecValid()

View File

@ -171,7 +171,7 @@ class NetEq {
// The speech type is written to |type|, if |type| is not NULL.
// Returns kOK on success, or kFail in case of an error.
virtual int GetAudio(size_t max_length, int16_t* output_audio,
size_t* samples_per_channel, int* num_channels,
size_t* samples_per_channel, size_t* num_channels,
NetEqOutputType* type) = 0;
// Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the

View File

@ -188,7 +188,7 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest,
void GetAndVerifyOutput() override {
NetEqOutputType output_type;
size_t samples_per_channel;
int num_channels;
size_t num_channels;
// Get audio from internal decoder instance.
EXPECT_EQ(NetEq::kOK,
neteq_internal_->GetAudio(kMaxBlockSize,
@ -196,7 +196,7 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest,
&samples_per_channel,
&num_channels,
&output_type));
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000),
samples_per_channel);

View File

@ -151,7 +151,7 @@ int NetEqImpl::InsertSyncPacket(const WebRtcRTPHeader& rtp_header,
}
int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio,
size_t* samples_per_channel, int* num_channels,
size_t* samples_per_channel, size_t* num_channels,
NetEqOutputType* type) {
TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio");
CriticalSectionScoped lock(crit_sect_.get());
@ -744,7 +744,7 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
int NetEqImpl::GetAudioInternal(size_t max_length,
int16_t* output,
size_t* samples_per_channel,
int* num_channels) {
size_t* num_channels) {
PacketList packet_list;
DtmfEvent dtmf_event;
Operations operation;
@ -868,7 +868,7 @@ int NetEqImpl::GetAudioInternal(size_t max_length,
const size_t samples_from_sync =
sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel,
output);
*num_channels = static_cast<int>(sync_buffer_->Channels());
*num_channels = sync_buffer_->Channels();
if (sync_buffer_->FutureLength() < expand_->overlap_length()) {
// The sync buffer should always contain |overlap_length| samples, but now
// too many samples have been extracted. Reinstall the |overlap_length|

View File

@ -107,7 +107,7 @@ class NetEqImpl : public webrtc::NetEq {
int GetAudio(size_t max_length,
int16_t* output_audio,
size_t* samples_per_channel,
int* num_channels,
size_t* num_channels,
NetEqOutputType* type) override;
int RegisterPayloadType(NetEqDecoder codec,
@ -220,7 +220,8 @@ class NetEqImpl : public webrtc::NetEq {
int GetAudioInternal(size_t max_length,
int16_t* output,
size_t* samples_per_channel,
int* num_channels) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
size_t* num_channels)
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
// Provides a decision to the GetAudioInternal method. The decision what to
// do is written to |operation|. Packets to decode are written to

View File

@ -466,14 +466,14 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(
NetEq::kOK,
neteq_->GetAudio(
kMaxOutputSize, output, &samples_per_channel, &num_channels, &type));
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
// Start with a simple check that the fake decoder is behaving as expected.
@ -545,14 +545,14 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(
NetEq::kOK,
neteq_->GetAudio(
kMaxOutputSize, output, &samples_per_channel, &num_channels, &type));
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
// Insert two more packets. The first one is out of order, and is already too
@ -583,7 +583,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
neteq_->GetAudio(
kMaxOutputSize, output, &samples_per_channel, &num_channels, &type));
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
// Now check the packet buffer, and make sure it is empty, since the
@ -622,14 +622,14 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
ASSERT_LE(samples_per_channel, kMaxOutputSize);
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputPLC, type);
// Register the payload type.
@ -652,7 +652,7 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) {
&num_channels, &type));
ASSERT_LE(samples_per_channel, kMaxOutputSize);
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type)
<< "NetEq did not decode the packets as expected.";
}
@ -734,7 +734,7 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
uint32_t timestamp;
uint32_t last_timestamp;
NetEqOutputType type;
@ -759,7 +759,7 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
for (size_t i = 1; i < 6; ++i) {
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(expected_type[i - 1], type);
EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&timestamp));
EXPECT_EQ(NetEq::kOK,
@ -779,7 +779,7 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
for (size_t i = 6; i < 8; ++i) {
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(expected_type[i - 1], type);
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
@ -799,7 +799,7 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) {
UseNoMocks();
CreateInstance();
static const size_t kNetEqMaxFrameSize = 2880; // 60 ms @ 48 kHz.
static const int kChannels = 2;
static const size_t kChannels = 2;
const uint8_t kPayloadType = 17; // Just an arbitrary number.
const uint32_t kReceiveTime = 17; // Value doesn't matter for this test.
@ -871,11 +871,10 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) {
EXPECT_EQ(NetEq::kOK,
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
const size_t kMaxOutputSize =
static_cast<size_t>(10 * kSampleRateHz / 1000 * kChannels);
const size_t kMaxOutputSize = 10 * kSampleRateHz / 1000 * kChannels;
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(kMaxOutputSize, output,
@ -981,13 +980,13 @@ TEST_F(NetEqImplTest, DecodedPayloadTooShort) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
EXPECT_CALL(mock_decoder, Die());
@ -1078,13 +1077,13 @@ TEST_F(NetEqImplTest, DecodingError) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
// Pull audio again. Decoder fails.
@ -1094,7 +1093,7 @@ TEST_F(NetEqImplTest, DecodingError) {
EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError());
EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError());
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
// TODO(minyue): should NetEq better give kOutputPLC, since it is actually an
// expansion.
EXPECT_EQ(kOutputNormal, type);
@ -1104,7 +1103,7 @@ TEST_F(NetEqImplTest, DecodingError) {
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputPLC, type);
// Pull audio again, should behave normal.
@ -1112,7 +1111,7 @@ TEST_F(NetEqImplTest, DecodingError) {
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputNormal, type);
EXPECT_CALL(mock_decoder, Die());
@ -1199,13 +1198,13 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
int16_t output[kMaxOutputSize];
size_t samples_per_channel;
int num_channels;
size_t num_channels;
NetEqOutputType type;
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputCNG, type);
// Pull audio again. Decoder fails.
@ -1215,7 +1214,7 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) {
EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError());
EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError());
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
// TODO(minyue): should NetEq better give kOutputPLC, since it is actually an
// expansion.
EXPECT_EQ(kOutputCNG, type);
@ -1225,7 +1224,7 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) {
neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel,
&num_channels, &type));
EXPECT_EQ(kMaxOutputSize, samples_per_channel);
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(kOutputCNG, type);
EXPECT_CALL(mock_decoder, Die());

View File

@ -27,7 +27,7 @@ namespace webrtc {
struct TestParameters {
int frame_size;
int sample_rate;
int num_channels;
size_t num_channels;
};
// This is a parameterized test. The test parameters are supplied through a
@ -163,7 +163,7 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
void VerifyOutput(size_t num_samples) {
for (size_t i = 0; i < num_samples; ++i) {
for (int j = 0; j < num_channels_; ++j) {
for (size_t j = 0; j < num_channels_; ++j) {
ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) <<
"Diff in sample " << i << ", channel " << j << ".";
}
@ -214,12 +214,12 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
NetEqOutputType output_type;
// Get audio from mono instance.
size_t samples_per_channel;
int num_channels;
size_t num_channels;
EXPECT_EQ(NetEq::kOK,
neteq_mono_->GetAudio(kMaxBlockSize, output_,
&samples_per_channel, &num_channels,
&output_type));
EXPECT_EQ(1, num_channels);
EXPECT_EQ(1u, num_channels);
EXPECT_EQ(output_size_samples_, samples_per_channel);
// Get audio from multi-channel instance.
ASSERT_EQ(NetEq::kOK,
@ -239,7 +239,7 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
}
}
const int num_channels_;
const size_t num_channels_;
const int sample_rate_hz_;
const int samples_per_ms_;
const int frame_size_ms_;

View File

@ -425,7 +425,7 @@ void NetEqDecodingTest::Process(size_t* out_len) {
// Get audio from NetEq.
NetEqOutputType type;
int num_channels;
size_t num_channels;
ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, out_len,
&num_channels, &type));
ASSERT_TRUE((*out_len == kBlockSize8kHz) ||
@ -608,7 +608,7 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
// Pull out all data.
for (size_t i = 0; i < num_frames; ++i) {
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
&num_channels, &type));
@ -653,7 +653,7 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
// Pull out data once.
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
&num_channels, &type));
@ -684,7 +684,7 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) {
// Pull out data once.
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
&num_channels, &type));
@ -709,7 +709,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
double next_input_time_ms = 0.0;
double t_ms;
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
// Insert speech for 5 seconds.
@ -948,7 +948,7 @@ TEST_F(NetEqDecodingTest, MAYBE_DecoderError) {
for (size_t i = 0; i < kMaxBlockSize; ++i) {
out_data_[i] = 1;
}
int num_channels;
size_t num_channels;
size_t samples_per_channel;
EXPECT_EQ(NetEq::kFail,
neteq_->GetAudio(kMaxBlockSize, out_data_,
@ -982,7 +982,7 @@ TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) {
for (size_t i = 0; i < kMaxBlockSize; ++i) {
out_data_[i] = 1;
}
int num_channels;
size_t num_channels;
size_t samples_per_channel;
EXPECT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_,
&samples_per_channel,
@ -1038,7 +1038,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
PopulateRtpInfo(0, 0, &rtp_info);
rtp_info.header.payloadType = payload_type;
int number_channels = 0;
size_t number_channels = 0;
size_t samples_per_channel = 0;
uint32_t receive_timestamp = 0;
@ -1060,7 +1060,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
&samples_per_channel,
&number_channels,
&type));
ASSERT_EQ(1, number_channels);
ASSERT_EQ(1u, number_channels);
ASSERT_EQ(expected_samples_per_channel, samples_per_channel);
ASSERT_EQ(kOutputNormal, type);
@ -1082,7 +1082,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
&samples_per_channel,
&number_channels,
&type));
ASSERT_EQ(1, number_channels);
ASSERT_EQ(1u, number_channels);
ASSERT_EQ(expected_samples_per_channel, samples_per_channel);
// To be able to test the fading of background noise we need at lease to
@ -1103,7 +1103,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
&samples_per_channel,
&number_channels,
&type));
ASSERT_EQ(1, number_channels);
ASSERT_EQ(1u, number_channels);
ASSERT_EQ(expected_samples_per_channel, samples_per_channel);
if (type == kOutputPLCtoCNG) {
plc_to_cng = true;
@ -1272,7 +1272,7 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
// Insert some packets which decode to noise. We are not interested in
// actual decoded values.
NetEqOutputType output_type;
int num_channels;
size_t num_channels;
size_t samples_per_channel;
uint32_t receive_timestamp = 0;
for (int n = 0; n < 100; ++n) {
@ -1281,7 +1281,7 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
&samples_per_channel, &num_channels,
&output_type));
ASSERT_EQ(kBlockSize16kHz, samples_per_channel);
ASSERT_EQ(1, num_channels);
ASSERT_EQ(1u, num_channels);
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
@ -1299,7 +1299,7 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
&samples_per_channel, &num_channels,
&output_type));
ASSERT_EQ(kBlockSize16kHz, samples_per_channel);
ASSERT_EQ(1, num_channels);
ASSERT_EQ(1u, num_channels);
if (n > algorithmic_frame_delay) {
EXPECT_TRUE(IsAllZero(decoded, samples_per_channel * num_channels));
}
@ -1348,7 +1348,7 @@ TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
// Insert some packets which decode to noise. We are not interested in
// actual decoded values.
NetEqOutputType output_type;
int num_channels;
size_t num_channels;
size_t samples_per_channel;
uint32_t receive_timestamp = 0;
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
@ -1358,7 +1358,7 @@ TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
&samples_per_channel, &num_channels,
&output_type));
ASSERT_EQ(kBlockSize16kHz, samples_per_channel);
ASSERT_EQ(1, num_channels);
ASSERT_EQ(1u, num_channels);
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
@ -1397,7 +1397,7 @@ TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
&samples_per_channel, &num_channels,
&output_type));
ASSERT_EQ(kBlockSize16kHz, samples_per_channel);
ASSERT_EQ(1, num_channels);
ASSERT_EQ(1u, num_channels);
EXPECT_TRUE(IsAllNonZero(decoded, samples_per_channel * num_channels));
}
}
@ -1415,7 +1415,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
const size_t kPayloadBytes = kSamples * sizeof(int16_t);
double next_input_time_ms = 0.0;
int16_t decoded[kBlockSize16kHz];
int num_channels;
size_t num_channels;
size_t samples_per_channel;
NetEqOutputType output_type;
uint32_t receive_timestamp = 0;
@ -1468,7 +1468,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
&samples_per_channel, &num_channels,
&output_type));
ASSERT_EQ(kBlockSize16kHz, samples_per_channel);
ASSERT_EQ(1, num_channels);
ASSERT_EQ(1u, num_channels);
// Expect delay (in samples) to be less than 2 packets.
EXPECT_LE(timestamp - PlayoutTimestamp(),
@ -1519,7 +1519,7 @@ void NetEqDecodingTest::DuplicateCng() {
// Insert three speech packets. Three are needed to get the frame length
// correct.
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
uint8_t payload[kPayloadBytes] = {0};
WebRtcRTPHeader rtp_info;
@ -1622,7 +1622,7 @@ TEST_F(NetEqDecodingTest, CngFirst) {
// Pull audio once and make sure CNG is played.
size_t out_len;
int num_channels;
size_t num_channels;
NetEqOutputType type;
ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
&num_channels, &type));

View File

@ -50,7 +50,7 @@ class NetEqIlbcQualityTest : public NetEqQualityTest {
NetEqDecoder::kDecoderILBC) {}
void SetUp() override {
ASSERT_EQ(1, channels_) << "iLBC supports only mono audio.";
ASSERT_EQ(1u, channels_) << "iLBC supports only mono audio.";
AudioEncoderIlbc::Config config;
config.frame_size_ms = FLAGS_frame_size_ms;
encoder_.reset(new AudioEncoderIlbc(config));

View File

@ -59,7 +59,7 @@ NetEqIsacQualityTest::NetEqIsacQualityTest()
bit_rate_kbps_(FLAGS_bit_rate_kbps) {}
void NetEqIsacQualityTest::SetUp() {
ASSERT_EQ(1, channels_) << "iSAC supports only mono audio.";
ASSERT_EQ(1u, channels_) << "iSAC supports only mono audio.";
// Create encoder memory.
WebRtcIsacfix_Create(&isac_encoder_);
ASSERT_TRUE(isac_encoder_ != NULL);

View File

@ -50,7 +50,7 @@ class NetEqPcmuQualityTest : public NetEqQualityTest {
NetEqDecoder::kDecoderPCMu) {}
void SetUp() override {
ASSERT_EQ(1, channels_) << "PCMu supports only mono audio.";
ASSERT_EQ(1u, channels_) << "PCMu supports only mono audio.";
AudioEncoderPcmU::Config config;
config.frame_size_ms = FLAGS_frame_size_ms;
encoder_.reset(new AudioEncoderPcmU(config));

View File

@ -12,6 +12,7 @@
#include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/format_macros.h"
namespace webrtc {
namespace test {
@ -21,11 +22,11 @@ NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec,
: codec_(codec),
decoder_(decoder),
sample_rate_hz_(CodecSampleRateHz(codec_)),
channels_(static_cast<int>(decoder_->Channels())) {
channels_(decoder_->Channels()) {
NetEq::Config config;
config.sample_rate_hz = sample_rate_hz_;
neteq_.reset(NetEq::Create(config));
printf("%d\n", channels_);
printf("%" PRIuS "\n", channels_);
}
void NetEqExternalDecoderTest::Init() {
@ -47,7 +48,7 @@ size_t NetEqExternalDecoderTest::GetOutputAudio(size_t max_length,
NetEqOutputType* output_type) {
// Get audio from regular instance.
size_t samples_per_channel;
int num_channels;
size_t num_channels;
EXPECT_EQ(NetEq::kOK,
neteq_->GetAudio(max_length,
output,

View File

@ -54,7 +54,7 @@ class NetEqExternalDecoderTest {
std::string name_ = "dummy name";
AudioDecoder* decoder_;
int sample_rate_hz_;
int channels_;
size_t channels_;
rtc::scoped_ptr<NetEq> neteq_;
};

View File

@ -109,7 +109,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
static const size_t kOutDataLen =
kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels;
int16_t out_data[kOutDataLen];
int num_channels;
size_t num_channels;
size_t samples_per_channel;
int error = neteq->GetAudio(kOutDataLen, out_data, &samples_per_channel,
&num_channels, NULL);

View File

@ -210,7 +210,7 @@ NetEqQualityTest::NetEqQualityTest(int block_duration_ms,
int out_sampling_khz,
NetEqDecoder decoder_type)
: decoder_type_(decoder_type),
channels_(FLAGS_channels),
channels_(static_cast<size_t>(FLAGS_channels)),
decoded_time_ms_(0),
decodable_time_ms_(0),
drift_factor_(FLAGS_drift_factor),
@ -394,7 +394,7 @@ int NetEqQualityTest::Transmit() {
}
int NetEqQualityTest::DecodeBlock() {
int channels;
size_t channels;
size_t samples;
int ret = neteq_->GetAudio(out_size_samples_ * channels_, &out_data_[0],
&samples, &channels, NULL);

View File

@ -99,7 +99,7 @@ class NetEqQualityTest : public ::testing::Test {
std::ofstream& Log();
NetEqDecoder decoder_type_;
const int channels_;
const size_t channels_;
private:
int decoded_time_ms_;

View File

@ -609,7 +609,7 @@ int main(int argc, char* argv[]) {
static const size_t kOutDataLen =
kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels;
int16_t out_data[kOutDataLen];
int num_channels;
size_t num_channels;
size_t samples_per_channel;
int error = neteq->GetAudio(kOutDataLen, out_data, &samples_per_channel,
&num_channels, NULL);

View File

@ -52,7 +52,7 @@ Sender::Sender()
}
void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string in_file_name, int sample_rate, int channels) {
std::string in_file_name, int sample_rate, size_t channels) {
struct CodecInst sendCodec;
int noOfCodecs = acm->NumberOfCodecs();
int codecNo;
@ -123,7 +123,7 @@ Receiver::Receiver()
}
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string out_file_name, int channels) {
std::string out_file_name, size_t channels) {
struct CodecInst recvCodec = CodecInst();
int noOfCodecs;
EXPECT_EQ(0, acm->InitializeReceiver());

View File

@ -48,7 +48,7 @@ class Sender {
public:
Sender();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string in_file_name, int sample_rate, int channels);
std::string in_file_name, int sample_rate, size_t channels);
void Teardown();
void Run();
bool Add10MsData();
@ -71,7 +71,7 @@ class Receiver {
Receiver();
virtual ~Receiver() {};
void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string out_file_name, int channels);
std::string out_file_name, size_t channels);
void Teardown();
void Run();
virtual bool IncomingPacket();

View File

@ -62,7 +62,7 @@ void OpusTest::Perform() {
return;
#else
uint16_t frequency_hz;
int audio_channels;
size_t audio_channels;
int16_t test_cntr = 0;
// Open both mono and stereo test files in 32 kHz.
@ -205,7 +205,7 @@ void OpusTest::Perform() {
#endif
}
void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate,
size_t frame_length, int percent_loss) {
AudioFrame audio_frame;
int32_t out_freq_hz_b = out_file_.SamplingFrequency();

View File

@ -32,7 +32,7 @@ class OpusTest : public ACMTest {
private:
void Run(TestPackStereo* channel,
int channels,
size_t channels,
int bitrate,
size_t frame_length,
int percent_loss = 0);

View File

@ -153,7 +153,7 @@ class TargetDelayTest : public ::testing::Test {
ASSERT_EQ(0, acm_->PlayoutData10Ms(-1, &frame));
// Had to use ASSERT_TRUE, ASSERT_EQ generated error.
ASSERT_TRUE(kSampleRateHz == frame.sample_rate_hz_);
ASSERT_EQ(1, frame.num_channels_);
ASSERT_EQ(1u, frame.num_channels_);
ASSERT_TRUE(kSampleRateHz / 100 == frame.samples_per_channel_);
}
}

View File

@ -50,8 +50,8 @@ void MixFrames(AudioFrame* mixed_frame, AudioFrame* frame, bool use_limiter) {
}
// Return the max number of channels from a |list| composed of AudioFrames.
int MaxNumChannels(const AudioFrameList* list) {
int max_num_channels = 1;
size_t MaxNumChannels(const AudioFrameList* list) {
size_t max_num_channels = 1;
for (AudioFrameList::const_iterator iter = list->begin();
iter != list->end();
++iter) {
@ -278,7 +278,7 @@ int32_t AudioConferenceMixerImpl::Process() {
// with an API instead of dynamically.
// Find the max channels over all mixing lists.
const int num_mixed_channels = std::max(MaxNumChannels(&mixList),
const size_t num_mixed_channels = std::max(MaxNumChannels(&mixList),
std::max(MaxNumChannels(&additionalFramesList),
MaxNumChannels(&rampOutList)));

View File

@ -383,7 +383,7 @@ class MockAudioTransport : public AudioTransport {
int32_t(const void* audioSamples,
const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
const uint32_t totalDelayMS,
const int32_t clockDrift,
@ -393,7 +393,7 @@ class MockAudioTransport : public AudioTransport {
MOCK_METHOD8(NeedMorePlayData,
int32_t(const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
void* audioSamples,
size_t& nSamplesOut,
@ -423,7 +423,7 @@ class MockAudioTransport : public AudioTransport {
int32_t RealRecordedDataIsAvailable(const void* audioSamples,
const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
const uint32_t totalDelayMS,
const int32_t clockDrift,
@ -445,7 +445,7 @@ class MockAudioTransport : public AudioTransport {
int32_t RealNeedMorePlayData(const size_t nSamples,
const size_t nBytesPerSample,
const uint8_t nChannels,
const size_t nChannels,
const uint32_t samplesPerSec,
void* audioSamples,
size_t& nSamplesOut,
@ -521,10 +521,10 @@ class AudioDeviceTest : public ::testing::Test {
int record_sample_rate() const {
return record_parameters_.sample_rate();
}
int playout_channels() const {
size_t playout_channels() const {
return playout_parameters_.channels();
}
int record_channels() const {
size_t record_channels() const {
return record_parameters_.channels();
}
size_t playout_frames_per_10ms_buffer() const {
@ -931,7 +931,7 @@ TEST_F(AudioDeviceTest, StartPlayoutAndRecordingVerifyCallbacks) {
// not contain any explicit verification that the audio quality is perfect.
TEST_F(AudioDeviceTest, RunPlayoutWithFileAsSource) {
// TODO(henrika): extend test when mono output is supported.
EXPECT_EQ(1, playout_channels());
EXPECT_EQ(1u, playout_channels());
NiceMock<MockAudioTransport> mock(kPlayout);
const int num_callbacks = kFilePlayTimeInSec * kNumCallbacksPerSecond;
std::string file_name = GetFileName(playout_sample_rate());

View File

@ -214,9 +214,9 @@ void AudioManager::OnCacheAudioParameters(JNIEnv* env,
hardware_ns_ = hardware_ns;
low_latency_playout_ = low_latency_output;
// TODO(henrika): add support for stereo output.
playout_parameters_.reset(sample_rate, channels,
playout_parameters_.reset(sample_rate, static_cast<size_t>(channels),
static_cast<size_t>(output_buffer_size));
record_parameters_.reset(sample_rate, channels,
record_parameters_.reset(sample_rate, static_cast<size_t>(channels),
static_cast<size_t>(input_buffer_size));
}

View File

@ -82,14 +82,14 @@ TEST_F(AudioManagerTest, ShowAudioParameterInfo) {
PRINT("%saudio layer: %s\n", kTag,
low_latency_out ? "Low latency OpenSL" : "Java/JNI based AudioTrack");
PRINT("%ssample rate: %d Hz\n", kTag, playout_parameters_.sample_rate());
PRINT("%schannels: %d\n", kTag, playout_parameters_.channels());
PRINT("%schannels: %" PRIuS "\n", kTag, playout_parameters_.channels());
PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
playout_parameters_.frames_per_buffer(),
playout_parameters_.GetBufferSizeInMilliseconds());
PRINT("RECORD: \n");
PRINT("%saudio layer: %s\n", kTag, "Java/JNI based AudioRecord");
PRINT("%ssample rate: %d Hz\n", kTag, record_parameters_.sample_rate());
PRINT("%schannels: %d\n", kTag, record_parameters_.channels());
PRINT("%schannels: %" PRIuS "\n", kTag, record_parameters_.channels());
PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
record_parameters_.frames_per_buffer(),
record_parameters_.GetBufferSizeInMilliseconds());
@ -119,7 +119,7 @@ TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) {
AudioParameters params;
EXPECT_FALSE(params.is_valid());
EXPECT_EQ(0, params.sample_rate());
EXPECT_EQ(0, params.channels());
EXPECT_EQ(0U, params.channels());
EXPECT_EQ(0U, params.frames_per_buffer());
EXPECT_EQ(0U, params.frames_per_10ms_buffer());
EXPECT_EQ(0U, params.GetBytesPerFrame());
@ -131,7 +131,7 @@ TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) {
// Basic test of the AudioParameters class using non default construction.
TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) {
const int kSampleRate = 48000;
const int kChannels = 1;
const size_t kChannels = 1;
const size_t kFramesPerBuffer = 480;
const size_t kFramesPer10msBuffer = 480;
const size_t kBytesPerFrame = 2;

Some files were not shown because too many files have changed in this diff Show More