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

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

Issue 2019223004: Moves ownership of OpenSL engine object to Android audio manager (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback from magjed@ Created 4 years, 6 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
« no previous file with comments | « no previous file | webrtc/modules/audio_device/android/audio_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 14 #include <memory>
15 15
16 #include <jni.h> 16 #include <jni.h>
17 #include <SLES/OpenSLES.h>
17 18
18 #include "webrtc/base/thread_checker.h" 19 #include "webrtc/base/thread_checker.h"
19 #include "webrtc/modules/audio_device/android/audio_common.h" 20 #include "webrtc/modules/audio_device/android/audio_common.h"
20 #include "webrtc/modules/audio_device/audio_device_config.h" 21 #include "webrtc/modules/audio_device/audio_device_config.h"
21 #include "webrtc/modules/audio_device/include/audio_device_defines.h" 22 #include "webrtc/modules/audio_device/include/audio_device_defines.h"
23 #include "webrtc/modules/audio_device/android/opensles_common.h"
22 #include "webrtc/modules/audio_device/audio_device_generic.h" 24 #include "webrtc/modules/audio_device/audio_device_generic.h"
23 #include "webrtc/modules/utility/include/helpers_android.h" 25 #include "webrtc/modules/utility/include/helpers_android.h"
24 #include "webrtc/modules/utility/include/jvm_android.h" 26 #include "webrtc/modules/utility/include/jvm_android.h"
25 27
26 namespace webrtc { 28 namespace webrtc {
27 29
28 // Implements support for functions in the WebRTC audio stack for Android that 30 // Implements support for functions in the WebRTC audio stack for Android that
29 // relies on the AudioManager in android.media. It also populates an 31 // relies on the AudioManager in android.media. It also populates an
30 // AudioParameter structure with native audio parameters detected at 32 // AudioParameter structure with native audio parameters detected at
31 // construction. This class does not make any audio-related modifications 33 // construction. This class does not make any audio-related modifications
(...skipping 24 matching lines...) Expand all
56 jmethodID is_device_blacklisted_for_open_sles_usage_; 58 jmethodID is_device_blacklisted_for_open_sles_usage_;
57 }; 59 };
58 60
59 AudioManager(); 61 AudioManager();
60 ~AudioManager(); 62 ~AudioManager();
61 63
62 // Sets the currently active audio layer combination. Must be called before 64 // Sets the currently active audio layer combination. Must be called before
63 // Init(). 65 // Init().
64 void SetActiveAudioLayer(AudioDeviceModule::AudioLayer audio_layer); 66 void SetActiveAudioLayer(AudioDeviceModule::AudioLayer audio_layer);
65 67
68 // Creates and realizes the main (global) Open SL engine object and returns
69 // a reference to it. The engine object is only created at the first call
70 // since OpenSL ES for Android only supports a single engine per application.
71 // Subsequent calls returns the already created engine. The SL engine object
72 // is destroyed when the AudioManager object is deleted. It means that the
73 // engine object will be the first OpenSL ES object to be created and last
74 // object to be destroyed.
75 // Note that NULL will be returned unless the audio layer is specified as
76 // AudioDeviceModule::kAndroidOpenSLESAudio or
77 // AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio.
78 SLObjectItf GetOpenSLEngine();
79
66 // Initializes the audio manager and stores the current audio mode. 80 // Initializes the audio manager and stores the current audio mode.
67 bool Init(); 81 bool Init();
68 // Revert any setting done by Init(). 82 // Revert any setting done by Init().
69 bool Close(); 83 bool Close();
70 84
71 // Returns true if current audio mode is AudioManager.MODE_IN_COMMUNICATION. 85 // Returns true if current audio mode is AudioManager.MODE_IN_COMMUNICATION.
72 bool IsCommunicationModeEnabled() const; 86 bool IsCommunicationModeEnabled() const;
73 87
74 // Native audio parameters stored during construction. 88 // Native audio parameters stored during construction.
75 const AudioParameters& GetPlayoutAudioParameters(); 89 const AudioParameters& GetPlayoutAudioParameters();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 150
137 // Wraps the JNI interface pointer and methods associated with it. 151 // Wraps the JNI interface pointer and methods associated with it.
138 std::unique_ptr<JNIEnvironment> j_environment_; 152 std::unique_ptr<JNIEnvironment> j_environment_;
139 153
140 // Contains factory method for creating the Java object. 154 // Contains factory method for creating the Java object.
141 std::unique_ptr<NativeRegistration> j_native_registration_; 155 std::unique_ptr<NativeRegistration> j_native_registration_;
142 156
143 // Wraps the Java specific parts of the AudioManager. 157 // Wraps the Java specific parts of the AudioManager.
144 std::unique_ptr<AudioManager::JavaAudioManager> j_audio_manager_; 158 std::unique_ptr<AudioManager::JavaAudioManager> j_audio_manager_;
145 159
160 // Contains the selected audio layer specified by the AudioLayer enumerator
161 // in the AudioDeviceModule class.
146 AudioDeviceModule::AudioLayer audio_layer_; 162 AudioDeviceModule::AudioLayer audio_layer_;
147 163
164 // This object is the global entry point of the OpenSL ES API.
165 // After creating the engine object, the application can obtain this object‘s
166 // SLEngineItf interface. This interface contains creation methods for all
167 // the other object types in the API. None of these interface are realized
168 // by this class. It only provides access to the global engine object.
169 webrtc::ScopedSLObjectItf engine_object_;
170
148 // Set to true by Init() and false by Close(). 171 // Set to true by Init() and false by Close().
149 bool initialized_; 172 bool initialized_;
150 173
151 // True if device supports hardware (or built-in) AEC. 174 // True if device supports hardware (or built-in) AEC.
152 bool hardware_aec_; 175 bool hardware_aec_;
153 // True if device supports hardware (or built-in) AGC. 176 // True if device supports hardware (or built-in) AGC.
154 bool hardware_agc_; 177 bool hardware_agc_;
155 // True if device supports hardware (or built-in) NS. 178 // True if device supports hardware (or built-in) NS.
156 bool hardware_ns_; 179 bool hardware_ns_;
157 180
(...skipping 10 matching lines...) Expand all
168 // Contains native parameters (e.g. sample rate, channel configuration). 191 // Contains native parameters (e.g. sample rate, channel configuration).
169 // Set at construction in OnCacheAudioParameters() which is called from 192 // Set at construction in OnCacheAudioParameters() which is called from
170 // Java on the same thread as this object is created on. 193 // Java on the same thread as this object is created on.
171 AudioParameters playout_parameters_; 194 AudioParameters playout_parameters_;
172 AudioParameters record_parameters_; 195 AudioParameters record_parameters_;
173 }; 196 };
174 197
175 } // namespace webrtc 198 } // namespace webrtc
176 199
177 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ 200 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_device/android/audio_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698