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

Unified Diff: webrtc/modules/audio_device/android/fine_audio_buffer.cc

Issue 1305983003: Convert some more things to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Support Android's C89 mode Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/android/fine_audio_buffer.cc
diff --git a/webrtc/modules/audio_device/android/fine_audio_buffer.cc b/webrtc/modules/audio_device/android/fine_audio_buffer.cc
index 99f853a23e4436a78e68a0eddd65aa6537d6efb2..37f994b800b1b987f82224ab19249e26aa75598b 100644
--- a/webrtc/modules/audio_device/android/fine_audio_buffer.cc
+++ b/webrtc/modules/audio_device/android/fine_audio_buffer.cc
@@ -20,12 +20,12 @@
namespace webrtc {
FineAudioBuffer::FineAudioBuffer(AudioDeviceBuffer* device_buffer,
- int desired_frame_size_bytes,
+ size_t desired_frame_size_bytes,
int sample_rate)
: device_buffer_(device_buffer),
desired_frame_size_bytes_(desired_frame_size_bytes),
sample_rate_(sample_rate),
- samples_per_10_ms_(sample_rate_ * 10 / 1000),
+ samples_per_10_ms_(static_cast<size_t>(sample_rate_ * 10 / 1000)),
bytes_per_10_ms_(samples_per_10_ms_ * sizeof(int16_t)),
cached_buffer_start_(0),
cached_bytes_(0) {
@@ -35,7 +35,7 @@ FineAudioBuffer::FineAudioBuffer(AudioDeviceBuffer* device_buffer,
FineAudioBuffer::~FineAudioBuffer() {
}
-int FineAudioBuffer::RequiredBufferSizeBytes() {
+size_t FineAudioBuffer::RequiredBufferSizeBytes() {
// It is possible that we store the desired frame size - 1 samples. Since new
// audio frames are pulled in chunks of 10ms we will need a buffer that can
// hold desired_frame_size - 1 + 10ms of data. We omit the - 1.
@@ -56,13 +56,13 @@ void FineAudioBuffer::GetBufferData(int8_t* buffer) {
// |desired_frame_size_bytes_| is greater than 10ms of audio. Note that we
// write the audio after the cached bytes copied earlier.
int8_t* unwritten_buffer = &buffer[cached_bytes_];
- int bytes_left = desired_frame_size_bytes_ - cached_bytes_;
+ int bytes_left = static_cast<int>(desired_frame_size_bytes_ - cached_bytes_);
// Ceiling of integer division: 1 + ((x - 1) / y)
- int number_of_requests = 1 + (bytes_left - 1) / (bytes_per_10_ms_);
- for (int i = 0; i < number_of_requests; ++i) {
+ size_t number_of_requests = 1 + (bytes_left - 1) / (bytes_per_10_ms_);
+ for (size_t i = 0; i < number_of_requests; ++i) {
device_buffer_->RequestPlayoutData(samples_per_10_ms_);
int num_out = device_buffer_->GetPlayoutData(unwritten_buffer);
- if (num_out != samples_per_10_ms_) {
+ if (static_cast<size_t>(num_out) != samples_per_10_ms_) {
CHECK_EQ(num_out, 0);
cached_bytes_ = 0;
return;
@@ -74,14 +74,14 @@ void FineAudioBuffer::GetBufferData(int8_t* buffer) {
CHECK_LE(bytes_left, 0);
// Put the samples that were written to |buffer| but are not used in the
// cache.
- int cache_location = desired_frame_size_bytes_;
+ size_t cache_location = desired_frame_size_bytes_;
int8_t* cache_ptr = &buffer[cache_location];
cached_bytes_ = number_of_requests * bytes_per_10_ms_ -
(desired_frame_size_bytes_ - cached_bytes_);
// If cached_bytes_ is larger than the cache buffer, uninitialized memory
// will be read.
CHECK_LE(cached_bytes_, bytes_per_10_ms_);
- CHECK_EQ(-bytes_left, cached_bytes_);
+ CHECK_EQ(static_cast<size_t>(-bytes_left), cached_bytes_);
cached_buffer_start_ = 0;
memcpy(cache_buffer_.get(), cache_ptr, cached_bytes_);
}
« no previous file with comments | « webrtc/modules/audio_device/android/fine_audio_buffer.h ('k') | webrtc/modules/audio_device/android/opensles_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698