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

Side by Side Diff: webrtc/modules/audio_device/android/audio_manager.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, 9 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 12
13 #include <utility> 13 #include <utility>
14 14
15 #include <android/log.h> 15 #include <android/log.h>
16 16
17 #include "webrtc/base/arraysize.h" 17 #include "webrtc/base/arraysize.h"
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/modules/audio_device/android/audio_common.h" 19 #include "webrtc/modules/audio_device/android/audio_common.h"
21 #include "webrtc/modules/utility/include/helpers_android.h" 20 #include "webrtc/modules/utility/include/helpers_android.h"
22 21
23 #define TAG "AudioManager" 22 #define TAG "AudioManager"
24 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) 23 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
25 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) 24 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
26 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 25 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
27 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 26 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
28 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) 27 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
29 28
30 namespace webrtc { 29 namespace webrtc {
31 30
32 // AudioManager::JavaAudioManager implementation 31 // AudioManager::JavaAudioManager implementation
33 AudioManager::JavaAudioManager::JavaAudioManager( 32 AudioManager::JavaAudioManager::JavaAudioManager(
34 NativeRegistration* native_reg, 33 NativeRegistration* native_reg,
35 rtc::scoped_ptr<GlobalRef> audio_manager) 34 std::unique_ptr<GlobalRef> audio_manager)
36 : audio_manager_(std::move(audio_manager)), 35 : audio_manager_(std::move(audio_manager)),
37 init_(native_reg->GetMethodId("init", "()Z")), 36 init_(native_reg->GetMethodId("init", "()Z")),
38 dispose_(native_reg->GetMethodId("dispose", "()V")), 37 dispose_(native_reg->GetMethodId("dispose", "()V")),
39 is_communication_mode_enabled_( 38 is_communication_mode_enabled_(
40 native_reg->GetMethodId("isCommunicationModeEnabled", "()Z")), 39 native_reg->GetMethodId("isCommunicationModeEnabled", "()Z")),
41 is_device_blacklisted_for_open_sles_usage_( 40 is_device_blacklisted_for_open_sles_usage_(
42 native_reg->GetMethodId("isDeviceBlacklistedForOpenSLESUsage", 41 native_reg->GetMethodId("isDeviceBlacklistedForOpenSLESUsage",
43 "()Z")) { 42 "()Z")) {
44 ALOGD("JavaAudioManager::ctor%s", GetThreadInfo().c_str()); 43 ALOGD("JavaAudioManager::ctor%s", GetThreadInfo().c_str());
45 } 44 }
(...skipping 14 matching lines...) Expand all
60 return audio_manager_->CallBooleanMethod(is_communication_mode_enabled_); 59 return audio_manager_->CallBooleanMethod(is_communication_mode_enabled_);
61 } 60 }
62 61
63 bool AudioManager::JavaAudioManager::IsDeviceBlacklistedForOpenSLESUsage() { 62 bool AudioManager::JavaAudioManager::IsDeviceBlacklistedForOpenSLESUsage() {
64 return audio_manager_->CallBooleanMethod( 63 return audio_manager_->CallBooleanMethod(
65 is_device_blacklisted_for_open_sles_usage_); 64 is_device_blacklisted_for_open_sles_usage_);
66 } 65 }
67 66
68 // AudioManager implementation 67 // AudioManager implementation
69 AudioManager::AudioManager() 68 AudioManager::AudioManager()
70 : j_environment_(JVM::GetInstance()->environment()), 69 : j_environment_(rtc::ScopedToUnique(JVM::GetInstance()->environment())),
71 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), 70 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio),
72 initialized_(false), 71 initialized_(false),
73 hardware_aec_(false), 72 hardware_aec_(false),
74 hardware_agc_(false), 73 hardware_agc_(false),
75 hardware_ns_(false), 74 hardware_ns_(false),
76 low_latency_playout_(false), 75 low_latency_playout_(false),
77 delay_estimate_in_milliseconds_(0) { 76 delay_estimate_in_milliseconds_(0) {
78 ALOGD("ctor%s", GetThreadInfo().c_str()); 77 ALOGD("ctor%s", GetThreadInfo().c_str());
79 RTC_CHECK(j_environment_); 78 RTC_CHECK(j_environment_);
80 JNINativeMethod native_methods[] = { 79 JNINativeMethod native_methods[] = {
81 {"nativeCacheAudioParameters", 80 {"nativeCacheAudioParameters",
82 "(IIZZZZIIJ)V", 81 "(IIZZZZIIJ)V",
83 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; 82 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}};
84 j_native_registration_ = j_environment_->RegisterNatives( 83 j_native_registration_ = rtc::ScopedToUnique(j_environment_->RegisterNatives(
85 "org/webrtc/voiceengine/WebRtcAudioManager", 84 "org/webrtc/voiceengine/WebRtcAudioManager",
86 native_methods, arraysize(native_methods)); 85 native_methods, arraysize(native_methods)));
87 j_audio_manager_.reset(new JavaAudioManager( 86 j_audio_manager_.reset(new JavaAudioManager(
88 j_native_registration_.get(), 87 j_native_registration_.get(),
89 j_native_registration_->NewObject( 88 rtc::ScopedToUnique(j_native_registration_->NewObject(
90 "<init>", "(Landroid/content/Context;J)V", 89 "<init>", "(Landroid/content/Context;J)V",
91 JVM::GetInstance()->context(), PointerTojlong(this)))); 90 JVM::GetInstance()->context(), PointerTojlong(this)))));
92 } 91 }
93 92
94 AudioManager::~AudioManager() { 93 AudioManager::~AudioManager() {
95 ALOGD("~dtor%s", GetThreadInfo().c_str()); 94 ALOGD("~dtor%s", GetThreadInfo().c_str());
96 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 95 RTC_DCHECK(thread_checker_.CalledOnValidThread());
97 Close(); 96 Close();
98 } 97 }
99 98
100 void AudioManager::SetActiveAudioLayer( 99 void AudioManager::SetActiveAudioLayer(
101 AudioDeviceModule::AudioLayer audio_layer) { 100 AudioDeviceModule::AudioLayer audio_layer) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return playout_parameters_; 225 return playout_parameters_;
227 } 226 }
228 227
229 const AudioParameters& AudioManager::GetRecordAudioParameters() { 228 const AudioParameters& AudioManager::GetRecordAudioParameters() {
230 RTC_CHECK(record_parameters_.is_valid()); 229 RTC_CHECK(record_parameters_.is_valid());
231 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 230 RTC_DCHECK(thread_checker_.CalledOnValidThread());
232 return record_parameters_; 231 return record_parameters_;
233 } 232 }
234 233
235 } // namespace webrtc 234 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_manager.h ('k') | webrtc/modules/audio_device/android/audio_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698