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

Side by Side Diff: webrtc/modules/audio_device/android/audio_track_jni.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_device/android/audio_manager.h" 11 #include "webrtc/modules/audio_device/android/audio_manager.h"
12 #include "webrtc/modules/audio_device/android/audio_track_jni.h" 12 #include "webrtc/modules/audio_device/android/audio_track_jni.h"
13 13
14 #include <android/log.h> 14 #include <android/log.h>
15 15
16 #include "webrtc/base/arraysize.h" 16 #include "webrtc/base/arraysize.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/format_macros.h"
18 19
19 #define TAG "AudioTrackJni" 20 #define TAG "AudioTrackJni"
20 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) 21 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
21 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) 22 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
22 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 23 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
23 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 24 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
24 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) 25 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
25 26
26 namespace webrtc { 27 namespace webrtc {
27 28
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 211 }
211 212
212 void AudioTrackJni::OnCacheDirectBufferAddress( 213 void AudioTrackJni::OnCacheDirectBufferAddress(
213 JNIEnv* env, jobject byte_buffer) { 214 JNIEnv* env, jobject byte_buffer) {
214 ALOGD("OnCacheDirectBufferAddress"); 215 ALOGD("OnCacheDirectBufferAddress");
215 DCHECK(thread_checker_.CalledOnValidThread()); 216 DCHECK(thread_checker_.CalledOnValidThread());
216 direct_buffer_address_ = 217 direct_buffer_address_ =
217 env->GetDirectBufferAddress(byte_buffer); 218 env->GetDirectBufferAddress(byte_buffer);
218 jlong capacity = env->GetDirectBufferCapacity(byte_buffer); 219 jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
219 ALOGD("direct buffer capacity: %lld", capacity); 220 ALOGD("direct buffer capacity: %lld", capacity);
220 direct_buffer_capacity_in_bytes_ = static_cast<int> (capacity); 221 direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity);
221 frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / kBytesPerFrame; 222 frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / kBytesPerFrame;
222 ALOGD("frames_per_buffer: %d", frames_per_buffer_); 223 ALOGD("frames_per_buffer: %" PRIuS, frames_per_buffer_);
223 } 224 }
224 225
225 void JNICALL AudioTrackJni::GetPlayoutData( 226 void JNICALL AudioTrackJni::GetPlayoutData(
226 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack) { 227 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack) {
227 webrtc::AudioTrackJni* this_object = 228 webrtc::AudioTrackJni* this_object =
228 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack); 229 reinterpret_cast<webrtc::AudioTrackJni*> (nativeAudioTrack);
229 this_object->OnGetPlayoutData(length); 230 this_object->OnGetPlayoutData(static_cast<size_t>(length));
230 } 231 }
231 232
232 // This method is called on a high-priority thread from Java. The name of 233 // This method is called on a high-priority thread from Java. The name of
233 // the thread is 'AudioRecordTrack'. 234 // the thread is 'AudioRecordTrack'.
234 void AudioTrackJni::OnGetPlayoutData(int length) { 235 void AudioTrackJni::OnGetPlayoutData(size_t length) {
235 DCHECK(thread_checker_java_.CalledOnValidThread()); 236 DCHECK(thread_checker_java_.CalledOnValidThread());
236 DCHECK_EQ(frames_per_buffer_, length / kBytesPerFrame); 237 DCHECK_EQ(frames_per_buffer_, length / kBytesPerFrame);
237 if (!audio_device_buffer_) { 238 if (!audio_device_buffer_) {
238 ALOGE("AttachAudioBuffer has not been called!"); 239 ALOGE("AttachAudioBuffer has not been called!");
239 return; 240 return;
240 } 241 }
241 // Pull decoded data (in 16-bit PCM format) from jitter buffer. 242 // Pull decoded data (in 16-bit PCM format) from jitter buffer.
242 int samples = audio_device_buffer_->RequestPlayoutData(frames_per_buffer_); 243 int samples = audio_device_buffer_->RequestPlayoutData(frames_per_buffer_);
243 if (samples <= 0) { 244 if (samples <= 0) {
244 ALOGE("AudioDeviceBuffer::RequestPlayoutData failed!"); 245 ALOGE("AudioDeviceBuffer::RequestPlayoutData failed!");
245 return; 246 return;
246 } 247 }
247 DCHECK_EQ(samples, frames_per_buffer_); 248 DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_);
248 // Copy decoded data into common byte buffer to ensure that it can be 249 // Copy decoded data into common byte buffer to ensure that it can be
249 // written to the Java based audio track. 250 // written to the Java based audio track.
250 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_); 251 samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_);
251 DCHECK_EQ(length, kBytesPerFrame * samples); 252 DCHECK_EQ(length, kBytesPerFrame * samples);
252 } 253 }
253 254
254 } // namespace webrtc 255 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_track_jni.h ('k') | webrtc/modules/audio_device/audio_device_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698