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

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

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 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
13 13
14 #include <memory>
15
14 #include <jni.h> 16 #include <jni.h>
15 17
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/base/thread_checker.h" 18 #include "webrtc/base/thread_checker.h"
18 #include "webrtc/modules/audio_device/android/audio_common.h" 19 #include "webrtc/modules/audio_device/android/audio_common.h"
19 #include "webrtc/modules/audio_device/audio_device_config.h" 20 #include "webrtc/modules/audio_device/audio_device_config.h"
20 #include "webrtc/modules/audio_device/include/audio_device_defines.h" 21 #include "webrtc/modules/audio_device/include/audio_device_defines.h"
21 #include "webrtc/modules/audio_device/audio_device_generic.h" 22 #include "webrtc/modules/audio_device/audio_device_generic.h"
22 #include "webrtc/modules/utility/include/helpers_android.h" 23 #include "webrtc/modules/utility/include/helpers_android.h"
23 #include "webrtc/modules/utility/include/jvm_android.h" 24 #include "webrtc/modules/utility/include/jvm_android.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
26 27
27 // Implements support for functions in the WebRTC audio stack for Android that 28 // Implements support for functions in the WebRTC audio stack for Android that
28 // relies on the AudioManager in android.media. It also populates an 29 // relies on the AudioManager in android.media. It also populates an
29 // AudioParameter structure with native audio parameters detected at 30 // AudioParameter structure with native audio parameters detected at
30 // construction. This class does not make any audio-related modifications 31 // construction. This class does not make any audio-related modifications
31 // unless Init() is called. Caching audio parameters makes no changes but only 32 // unless Init() is called. Caching audio parameters makes no changes but only
32 // reads data from the Java side. 33 // reads data from the Java side.
33 class AudioManager { 34 class AudioManager {
34 public: 35 public:
35 // Wraps the Java specific parts of the AudioManager into one helper class. 36 // Wraps the Java specific parts of the AudioManager into one helper class.
36 // Stores method IDs for all supported methods at construction and then 37 // Stores method IDs for all supported methods at construction and then
37 // allows calls like JavaAudioManager::Close() while hiding the Java/JNI 38 // allows calls like JavaAudioManager::Close() while hiding the Java/JNI
38 // parts that are associated with this call. 39 // parts that are associated with this call.
39 class JavaAudioManager { 40 class JavaAudioManager {
40 public: 41 public:
41 JavaAudioManager(NativeRegistration* native_registration, 42 JavaAudioManager(NativeRegistration* native_registration,
42 rtc::scoped_ptr<GlobalRef> audio_manager); 43 std::unique_ptr<GlobalRef> audio_manager);
43 ~JavaAudioManager(); 44 ~JavaAudioManager();
44 45
45 bool Init(); 46 bool Init();
46 void Close(); 47 void Close();
47 bool IsCommunicationModeEnabled(); 48 bool IsCommunicationModeEnabled();
48 bool IsDeviceBlacklistedForOpenSLESUsage(); 49 bool IsDeviceBlacklistedForOpenSLESUsage();
49 50
50 private: 51 private:
51 rtc::scoped_ptr<GlobalRef> audio_manager_; 52 std::unique_ptr<GlobalRef> audio_manager_;
52 jmethodID init_; 53 jmethodID init_;
53 jmethodID dispose_; 54 jmethodID dispose_;
54 jmethodID is_communication_mode_enabled_; 55 jmethodID is_communication_mode_enabled_;
55 jmethodID is_device_blacklisted_for_open_sles_usage_; 56 jmethodID is_device_blacklisted_for_open_sles_usage_;
56 }; 57 };
57 58
58 AudioManager(); 59 AudioManager();
59 ~AudioManager(); 60 ~AudioManager();
60 61
61 // Sets the currently active audio layer combination. Must be called before 62 // Sets the currently active audio layer combination. Must be called before
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Stores thread ID in the constructor. 122 // Stores thread ID in the constructor.
122 // We can then use ThreadChecker::CalledOnValidThread() to ensure that 123 // We can then use ThreadChecker::CalledOnValidThread() to ensure that
123 // other methods are called from the same thread. 124 // other methods are called from the same thread.
124 rtc::ThreadChecker thread_checker_; 125 rtc::ThreadChecker thread_checker_;
125 126
126 // Calls AttachCurrentThread() if this thread is not attached at construction. 127 // Calls AttachCurrentThread() if this thread is not attached at construction.
127 // Also ensures that DetachCurrentThread() is called at destruction. 128 // Also ensures that DetachCurrentThread() is called at destruction.
128 AttachCurrentThreadIfNeeded attach_thread_if_needed_; 129 AttachCurrentThreadIfNeeded attach_thread_if_needed_;
129 130
130 // Wraps the JNI interface pointer and methods associated with it. 131 // Wraps the JNI interface pointer and methods associated with it.
131 rtc::scoped_ptr<JNIEnvironment> j_environment_; 132 std::unique_ptr<JNIEnvironment> j_environment_;
132 133
133 // Contains factory method for creating the Java object. 134 // Contains factory method for creating the Java object.
134 rtc::scoped_ptr<NativeRegistration> j_native_registration_; 135 std::unique_ptr<NativeRegistration> j_native_registration_;
135 136
136 // Wraps the Java specific parts of the AudioManager. 137 // Wraps the Java specific parts of the AudioManager.
137 rtc::scoped_ptr<AudioManager::JavaAudioManager> j_audio_manager_; 138 std::unique_ptr<AudioManager::JavaAudioManager> j_audio_manager_;
138 139
139 AudioDeviceModule::AudioLayer audio_layer_; 140 AudioDeviceModule::AudioLayer audio_layer_;
140 141
141 // Set to true by Init() and false by Close(). 142 // Set to true by Init() and false by Close().
142 bool initialized_; 143 bool initialized_;
143 144
144 // True if device supports hardware (or built-in) AEC. 145 // True if device supports hardware (or built-in) AEC.
145 bool hardware_aec_; 146 bool hardware_aec_;
146 // True if device supports hardware (or built-in) AGC. 147 // True if device supports hardware (or built-in) AGC.
147 bool hardware_agc_; 148 bool hardware_agc_;
(...skipping 10 matching lines...) Expand all
158 // Contains native parameters (e.g. sample rate, channel configuration). 159 // Contains native parameters (e.g. sample rate, channel configuration).
159 // Set at construction in OnCacheAudioParameters() which is called from 160 // Set at construction in OnCacheAudioParameters() which is called from
160 // Java on the same thread as this object is created on. 161 // Java on the same thread as this object is created on.
161 AudioParameters playout_parameters_; 162 AudioParameters playout_parameters_;
162 AudioParameters record_parameters_; 163 AudioParameters record_parameters_;
163 }; 164 };
164 165
165 } // namespace webrtc 166 } // namespace webrtc
166 167
167 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ 168 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_device_unittest.cc ('k') | webrtc/modules/audio_device/android/audio_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698