Android: Simplify moved audio device module

This CL performs some simplifications and cleanups of the moved audio code.
 * All JNI interaction now goes from the C++ audio manager calling into
   the Java audio manager. The calls back from the Java code to the C++
   audio manager are removed (this was related to caching audio parameters).
   It's simpler this way because the Java code is now unaware of the C++
   layer and it will be easier to make this into a Java interface.
 * A bunch of state was removed that was related to caching the audio parameters.
 * Some unused functions from audio manager was removed.
 * The Java audio manager no longer depends on ContextUtils, and the context has
   to be passed in externally instead. This is done because we want to get rid of
   ContextUtils eventually.
 * The selection of what AudioDeviceModule to create (AAudio, OpenSLES
   input/output is now exposed in the interface. The reason is that client should
   decide and create what they need explicitly instead of setting blacklists
   in static global WebRTC classes. This will be more modular long term.
 * Selection of what audio device module to create (OpenSLES combinations) no
   longer requires instantiating a C++ AudioManager and is done with static
   enumeration methods instead.

Bug: webrtc:7452
Change-Id: Iba29cf7447a1f6063abd9544d7315e10095167c8
Reviewed-on: https://webrtc-review.googlesource.com/63760
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22542}
This commit is contained in:
Magnus Jedvert
2018-03-21 17:26:09 +01:00
committed by Commit Bot
parent 2955d82eca
commit 32362a6729
10 changed files with 249 additions and 427 deletions

View File

@ -27,7 +27,6 @@ public class PeerConnectionFactory {
private final long nativeFactory;
private static volatile boolean internalTracerInitialized = false;
private static Context applicationContext;
private static Thread networkThread;
private static Thread workerThread;
private static Thread signalingThread;
@ -181,7 +180,7 @@ public class PeerConnectionFactory {
public static void initialize(InitializationOptions options) {
ContextUtils.initialize(options.applicationContext);
NativeLibrary.initialize(options.nativeLibraryLoader);
nativeInitializeAndroidGlobals(options.applicationContext, options.enableVideoHwAcceleration);
nativeInitializeAndroidGlobals(options.enableVideoHwAcceleration);
initializeFieldTrials(options.fieldTrials);
if (options.enableInternalTracer && !internalTracerInitialized) {
initializeInternalTracer();
@ -249,8 +248,8 @@ public class PeerConnectionFactory {
public PeerConnectionFactory(
Options options, VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory) {
checkInitializeHasBeenCalled();
nativeFactory =
nativeCreatePeerConnectionFactory(options, encoderFactory, decoderFactory, 0, 0);
nativeFactory = nativeCreatePeerConnectionFactory(
ContextUtils.getApplicationContext(), options, encoderFactory, decoderFactory, 0, 0);
if (nativeFactory == 0) {
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
}
@ -267,7 +266,8 @@ public class PeerConnectionFactory {
VideoDecoderFactory decoderFactory, AudioProcessingFactory audioProcessingFactory,
FecControllerFactoryFactoryInterface fecControllerFactoryFactory) {
checkInitializeHasBeenCalled();
nativeFactory = nativeCreatePeerConnectionFactory(options, encoderFactory, decoderFactory,
nativeFactory = nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
encoderFactory, decoderFactory,
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative());
if (nativeFactory == 0) {
@ -449,8 +449,7 @@ public class PeerConnectionFactory {
// Must be called at least once before creating a PeerConnectionFactory
// (for example, at application startup time).
private static native void nativeInitializeAndroidGlobals(
Context context, boolean videoHwAcceleration);
private static native void nativeInitializeAndroidGlobals(boolean videoHwAcceleration);
private static native void nativeInitializeFieldTrials(String fieldTrialsInitString);
private static native String nativeFindFieldTrialsFullName(String name);
// Internal tracing initialization. Must be called before PeerConnectionFactory is created to
@ -462,7 +461,7 @@ public class PeerConnectionFactory {
private static native void nativeShutdownInternalTracer();
private static native boolean nativeStartInternalTracingCapture(String tracingFilename);
private static native void nativeStopInternalTracingCapture();
private static native long nativeCreatePeerConnectionFactory(Options options,
private static native long nativeCreatePeerConnectionFactory(Context context, Options options,
VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory,
long nativeAudioProcessor, long nativeFecControllerFactory);
private static native long nativeCreatePeerConnection(long factory,