OLD | NEW |
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_record_jni.h" | 11 #include "webrtc/modules/audio_device/android/audio_record_jni.h" |
12 | 12 |
13 #include <android/log.h> | 13 #include <android/log.h> |
14 | 14 |
15 #include "webrtc/base/arraysize.h" | 15 #include "webrtc/base/arraysize.h" |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/format_macros.h" |
17 #include "webrtc/modules/audio_device/android/audio_common.h" | 18 #include "webrtc/modules/audio_device/android/audio_common.h" |
18 | 19 |
19 #define TAG "AudioRecordJni" | 20 #define TAG "AudioRecordJni" |
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 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 ALOGD("InitRecording%s", GetThreadInfo().c_str()); | 116 ALOGD("InitRecording%s", GetThreadInfo().c_str()); |
116 DCHECK(thread_checker_.CalledOnValidThread()); | 117 DCHECK(thread_checker_.CalledOnValidThread()); |
117 DCHECK(!initialized_); | 118 DCHECK(!initialized_); |
118 DCHECK(!recording_); | 119 DCHECK(!recording_); |
119 int frames_per_buffer = j_audio_record_->InitRecording( | 120 int frames_per_buffer = j_audio_record_->InitRecording( |
120 audio_parameters_.sample_rate(), audio_parameters_.channels()); | 121 audio_parameters_.sample_rate(), audio_parameters_.channels()); |
121 if (frames_per_buffer < 0) { | 122 if (frames_per_buffer < 0) { |
122 ALOGE("InitRecording failed!"); | 123 ALOGE("InitRecording failed!"); |
123 return -1; | 124 return -1; |
124 } | 125 } |
125 frames_per_buffer_ = frames_per_buffer; | 126 frames_per_buffer_ = static_cast<size_t>(frames_per_buffer); |
126 ALOGD("frames_per_buffer: %d", frames_per_buffer_); | 127 ALOGD("frames_per_buffer: %" PRIuS, frames_per_buffer_); |
127 CHECK_EQ(direct_buffer_capacity_in_bytes_, | 128 CHECK_EQ(direct_buffer_capacity_in_bytes_, |
128 frames_per_buffer_ * kBytesPerFrame); | 129 frames_per_buffer_ * kBytesPerFrame); |
129 CHECK_EQ(frames_per_buffer_, audio_parameters_.frames_per_10ms_buffer()); | 130 CHECK_EQ(frames_per_buffer_, audio_parameters_.frames_per_10ms_buffer()); |
130 initialized_ = true; | 131 initialized_ = true; |
131 return 0; | 132 return 0; |
132 } | 133 } |
133 | 134 |
134 int32_t AudioRecordJni::StartRecording() { | 135 int32_t AudioRecordJni::StartRecording() { |
135 ALOGD("StartRecording%s", GetThreadInfo().c_str()); | 136 ALOGD("StartRecording%s", GetThreadInfo().c_str()); |
136 DCHECK(thread_checker_.CalledOnValidThread()); | 137 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 void AudioRecordJni::OnCacheDirectBufferAddress( | 195 void AudioRecordJni::OnCacheDirectBufferAddress( |
195 JNIEnv* env, jobject byte_buffer) { | 196 JNIEnv* env, jobject byte_buffer) { |
196 ALOGD("OnCacheDirectBufferAddress"); | 197 ALOGD("OnCacheDirectBufferAddress"); |
197 DCHECK(thread_checker_.CalledOnValidThread()); | 198 DCHECK(thread_checker_.CalledOnValidThread()); |
198 DCHECK(!direct_buffer_address_); | 199 DCHECK(!direct_buffer_address_); |
199 direct_buffer_address_ = | 200 direct_buffer_address_ = |
200 env->GetDirectBufferAddress(byte_buffer); | 201 env->GetDirectBufferAddress(byte_buffer); |
201 jlong capacity = env->GetDirectBufferCapacity(byte_buffer); | 202 jlong capacity = env->GetDirectBufferCapacity(byte_buffer); |
202 ALOGD("direct buffer capacity: %lld", capacity); | 203 ALOGD("direct buffer capacity: %lld", capacity); |
203 direct_buffer_capacity_in_bytes_ = static_cast<int> (capacity); | 204 direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity); |
204 } | 205 } |
205 | 206 |
206 void JNICALL AudioRecordJni::DataIsRecorded( | 207 void JNICALL AudioRecordJni::DataIsRecorded( |
207 JNIEnv* env, jobject obj, jint length, jlong nativeAudioRecord) { | 208 JNIEnv* env, jobject obj, jint length, jlong nativeAudioRecord) { |
208 webrtc::AudioRecordJni* this_object = | 209 webrtc::AudioRecordJni* this_object = |
209 reinterpret_cast<webrtc::AudioRecordJni*> (nativeAudioRecord); | 210 reinterpret_cast<webrtc::AudioRecordJni*> (nativeAudioRecord); |
210 this_object->OnDataIsRecorded(length); | 211 this_object->OnDataIsRecorded(length); |
211 } | 212 } |
212 | 213 |
213 // This method is called on a high-priority thread from Java. The name of | 214 // This method is called on a high-priority thread from Java. The name of |
(...skipping 11 matching lines...) Expand all Loading... |
225 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. | 226 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. |
226 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, | 227 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, |
227 0, // recDelayMs | 228 0, // recDelayMs |
228 0); // clockDrift | 229 0); // clockDrift |
229 if (audio_device_buffer_->DeliverRecordedData() == -1) { | 230 if (audio_device_buffer_->DeliverRecordedData() == -1) { |
230 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); | 231 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); |
231 } | 232 } |
232 } | 233 } |
233 | 234 |
234 } // namespace webrtc | 235 } // namespace webrtc |
OLD | NEW |