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

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

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, 3 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
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack); 92 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack);
93 void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer); 93 void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer);
94 94
95 // Called periodically by the Java based WebRtcAudioTrack object when 95 // Called periodically by the Java based WebRtcAudioTrack object when
96 // playout has started. Each call indicates that |length| new bytes should 96 // playout has started. Each call indicates that |length| new bytes should
97 // be written to the memory area |direct_buffer_address_| for playout. 97 // be written to the memory area |direct_buffer_address_| for playout.
98 // This method is called on a high-priority thread from Java. The name of 98 // This method is called on a high-priority thread from Java. The name of
99 // the thread is 'AudioTrackThread'. 99 // the thread is 'AudioTrackThread'.
100 static void JNICALL GetPlayoutData( 100 static void JNICALL GetPlayoutData(
101 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack); 101 JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack);
102 void OnGetPlayoutData(int length); 102 void OnGetPlayoutData(size_t length);
103 103
104 // Stores thread ID in constructor. 104 // Stores thread ID in constructor.
105 rtc::ThreadChecker thread_checker_; 105 rtc::ThreadChecker thread_checker_;
106 106
107 // Stores thread ID in first call to OnGetPlayoutData() from high-priority 107 // Stores thread ID in first call to OnGetPlayoutData() from high-priority
108 // thread in Java. Detached during construction of this object. 108 // thread in Java. Detached during construction of this object.
109 rtc::ThreadChecker thread_checker_java_; 109 rtc::ThreadChecker thread_checker_java_;
110 110
111 // Calls AttachCurrentThread() if this thread is not attached at construction. 111 // Calls AttachCurrentThread() if this thread is not attached at construction.
112 // Also ensures that DetachCurrentThread() is called at destruction. 112 // Also ensures that DetachCurrentThread() is called at destruction.
113 AttachCurrentThreadIfNeeded attach_thread_if_needed_; 113 AttachCurrentThreadIfNeeded attach_thread_if_needed_;
114 114
115 // Wraps the JNI interface pointer and methods associated with it. 115 // Wraps the JNI interface pointer and methods associated with it.
116 rtc::scoped_ptr<JNIEnvironment> j_environment_; 116 rtc::scoped_ptr<JNIEnvironment> j_environment_;
117 117
118 // Contains factory method for creating the Java object. 118 // Contains factory method for creating the Java object.
119 rtc::scoped_ptr<NativeRegistration> j_native_registration_; 119 rtc::scoped_ptr<NativeRegistration> j_native_registration_;
120 120
121 // Wraps the Java specific parts of the AudioTrackJni class. 121 // Wraps the Java specific parts of the AudioTrackJni class.
122 rtc::scoped_ptr<AudioTrackJni::JavaAudioTrack> j_audio_track_; 122 rtc::scoped_ptr<AudioTrackJni::JavaAudioTrack> j_audio_track_;
123 123
124 // Contains audio parameters provided to this class at construction by the 124 // Contains audio parameters provided to this class at construction by the
125 // AudioManager. 125 // AudioManager.
126 const AudioParameters audio_parameters_; 126 const AudioParameters audio_parameters_;
127 127
128 // Cached copy of address to direct audio buffer owned by |j_audio_track_|. 128 // Cached copy of address to direct audio buffer owned by |j_audio_track_|.
129 void* direct_buffer_address_; 129 void* direct_buffer_address_;
130 130
131 // Number of bytes in the direct audio buffer owned by |j_audio_track_|. 131 // Number of bytes in the direct audio buffer owned by |j_audio_track_|.
132 int direct_buffer_capacity_in_bytes_; 132 size_t direct_buffer_capacity_in_bytes_;
133 133
134 // Number of audio frames per audio buffer. Each audio frame corresponds to 134 // Number of audio frames per audio buffer. Each audio frame corresponds to
135 // one sample of PCM mono data at 16 bits per sample. Hence, each audio 135 // one sample of PCM mono data at 16 bits per sample. Hence, each audio
136 // frame contains 2 bytes (given that the Java layer only supports mono). 136 // frame contains 2 bytes (given that the Java layer only supports mono).
137 // Example: 480 for 48000 Hz or 441 for 44100 Hz. 137 // Example: 480 for 48000 Hz or 441 for 44100 Hz.
138 int frames_per_buffer_; 138 size_t frames_per_buffer_;
139 139
140 bool initialized_; 140 bool initialized_;
141 141
142 bool playing_; 142 bool playing_;
143 143
144 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the 144 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the
145 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). 145 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create().
146 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance 146 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance
147 // and therefore outlives this object. 147 // and therefore outlives this object.
148 AudioDeviceBuffer* audio_device_buffer_; 148 AudioDeviceBuffer* audio_device_buffer_;
149 }; 149 };
150 150
151 } // namespace webrtc 151 } // namespace webrtc
152 152
153 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ 153 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_record_jni.cc ('k') | webrtc/modules/audio_device/android/audio_track_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698