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

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

Issue 1722083002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_device/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 13 matching lines...) Expand all
24 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) 24 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
25 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 25 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
26 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 26 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
27 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) 27 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 // AudioRecordJni::JavaAudioRecord implementation. 31 // AudioRecordJni::JavaAudioRecord implementation.
32 AudioRecordJni::JavaAudioRecord::JavaAudioRecord( 32 AudioRecordJni::JavaAudioRecord::JavaAudioRecord(
33 NativeRegistration* native_reg, 33 NativeRegistration* native_reg,
34 rtc::scoped_ptr<GlobalRef> audio_record) 34 std::unique_ptr<GlobalRef> audio_record)
35 : audio_record_(std::move(audio_record)), 35 : audio_record_(std::move(audio_record)),
36 init_recording_(native_reg->GetMethodId("initRecording", "(II)I")), 36 init_recording_(native_reg->GetMethodId("initRecording", "(II)I")),
37 start_recording_(native_reg->GetMethodId("startRecording", "()Z")), 37 start_recording_(native_reg->GetMethodId("startRecording", "()Z")),
38 stop_recording_(native_reg->GetMethodId("stopRecording", "()Z")), 38 stop_recording_(native_reg->GetMethodId("stopRecording", "()Z")),
39 enable_built_in_aec_(native_reg->GetMethodId("enableBuiltInAEC", "(Z)Z")), 39 enable_built_in_aec_(native_reg->GetMethodId("enableBuiltInAEC", "(Z)Z")),
40 enable_built_in_agc_(native_reg->GetMethodId("enableBuiltInAGC", "(Z)Z")), 40 enable_built_in_agc_(native_reg->GetMethodId("enableBuiltInAGC", "(Z)Z")),
41 enable_built_in_ns_(native_reg->GetMethodId("enableBuiltInNS", "(Z)Z")) {} 41 enable_built_in_ns_(native_reg->GetMethodId("enableBuiltInNS", "(Z)Z")) {}
42 42
43 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {} 43 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {}
44 44
(...skipping 22 matching lines...) Expand all
67 static_cast<jboolean>(enable)); 67 static_cast<jboolean>(enable));
68 } 68 }
69 69
70 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInNS(bool enable) { 70 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInNS(bool enable) {
71 return audio_record_->CallBooleanMethod(enable_built_in_ns_, 71 return audio_record_->CallBooleanMethod(enable_built_in_ns_,
72 static_cast<jboolean>(enable)); 72 static_cast<jboolean>(enable));
73 } 73 }
74 74
75 // AudioRecordJni implementation. 75 // AudioRecordJni implementation.
76 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) 76 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager)
77 : j_environment_(JVM::GetInstance()->environment()), 77 : j_environment_(rtc::ScopedToUnique(JVM::GetInstance()->environment())),
78 audio_manager_(audio_manager), 78 audio_manager_(audio_manager),
79 audio_parameters_(audio_manager->GetRecordAudioParameters()), 79 audio_parameters_(audio_manager->GetRecordAudioParameters()),
80 total_delay_in_milliseconds_(0), 80 total_delay_in_milliseconds_(0),
81 direct_buffer_address_(nullptr), 81 direct_buffer_address_(nullptr),
82 direct_buffer_capacity_in_bytes_(0), 82 direct_buffer_capacity_in_bytes_(0),
83 frames_per_buffer_(0), 83 frames_per_buffer_(0),
84 initialized_(false), 84 initialized_(false),
85 recording_(false), 85 recording_(false),
86 audio_device_buffer_(nullptr) { 86 audio_device_buffer_(nullptr) {
87 ALOGD("ctor%s", GetThreadInfo().c_str()); 87 ALOGD("ctor%s", GetThreadInfo().c_str());
88 RTC_DCHECK(audio_parameters_.is_valid()); 88 RTC_DCHECK(audio_parameters_.is_valid());
89 RTC_CHECK(j_environment_); 89 RTC_CHECK(j_environment_);
90 JNINativeMethod native_methods[] = { 90 JNINativeMethod native_methods[] = {
91 {"nativeCacheDirectBufferAddress", "(Ljava/nio/ByteBuffer;J)V", 91 {"nativeCacheDirectBufferAddress", "(Ljava/nio/ByteBuffer;J)V",
92 reinterpret_cast<void*>( 92 reinterpret_cast<void*>(
93 &webrtc::AudioRecordJni::CacheDirectBufferAddress)}, 93 &webrtc::AudioRecordJni::CacheDirectBufferAddress)},
94 {"nativeDataIsRecorded", "(IJ)V", 94 {"nativeDataIsRecorded", "(IJ)V",
95 reinterpret_cast<void*>(&webrtc::AudioRecordJni::DataIsRecorded)}}; 95 reinterpret_cast<void*>(&webrtc::AudioRecordJni::DataIsRecorded)}};
96 j_native_registration_ = j_environment_->RegisterNatives( 96 j_native_registration_ = rtc::ScopedToUnique(j_environment_->RegisterNatives(
97 "org/webrtc/voiceengine/WebRtcAudioRecord", 97 "org/webrtc/voiceengine/WebRtcAudioRecord",
98 native_methods, arraysize(native_methods)); 98 native_methods, arraysize(native_methods)));
99 j_audio_record_.reset(new JavaAudioRecord( 99 j_audio_record_.reset(new JavaAudioRecord(
100 j_native_registration_.get(), 100 j_native_registration_.get(),
101 j_native_registration_->NewObject( 101 rtc::ScopedToUnique(j_native_registration_->NewObject(
102 "<init>", "(Landroid/content/Context;J)V", 102 "<init>", "(Landroid/content/Context;J)V",
103 JVM::GetInstance()->context(), PointerTojlong(this)))); 103 JVM::GetInstance()->context(), PointerTojlong(this)))));
104 // Detach from this thread since we want to use the checker to verify calls 104 // Detach from this thread since we want to use the checker to verify calls
105 // from the Java based audio thread. 105 // from the Java based audio thread.
106 thread_checker_java_.DetachFromThread(); 106 thread_checker_java_.DetachFromThread();
107 } 107 }
108 108
109 AudioRecordJni::~AudioRecordJni() { 109 AudioRecordJni::~AudioRecordJni() {
110 ALOGD("~dtor%s", GetThreadInfo().c_str()); 110 ALOGD("~dtor%s", GetThreadInfo().c_str());
111 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 111 RTC_DCHECK(thread_checker_.CalledOnValidThread());
112 Terminate(); 112 Terminate();
113 } 113 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. 253 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter.
254 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, 254 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_,
255 0, // recDelayMs 255 0, // recDelayMs
256 0); // clockDrift 256 0); // clockDrift
257 if (audio_device_buffer_->DeliverRecordedData() == -1) { 257 if (audio_device_buffer_->DeliverRecordedData() == -1) {
258 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); 258 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!");
259 } 259 }
260 } 260 }
261 261
262 } // namespace webrtc 262 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_record_jni.h ('k') | webrtc/modules/audio_device/android/audio_track_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698