Android audio code: Replace C++ template with input/output interface

Bug: webrtc:7452
Change-Id: Id816500051e065918bba5c2235d38ad8eb50a8eb
Reviewed-on: https://webrtc-review.googlesource.com/64442
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22660}
This commit is contained in:
Magnus Jedvert
2018-03-28 16:51:15 +02:00
committed by Commit Bot
parent 85eef49fa2
commit 1a18e0ac46
21 changed files with 321 additions and 286 deletions

View File

@ -42,20 +42,6 @@ class WebRtcAudioManager {
private static boolean useStereoOutput = false;
private static boolean useStereoInput = false;
private static boolean blacklistDeviceForOpenSLESUsage = false;
private static boolean blacklistDeviceForOpenSLESUsageIsOverridden = false;
// Call this method to override the default list of blacklisted devices
// specified in WebRtcAudioUtils.BLACKLISTED_OPEN_SL_ES_MODELS.
// Allows an app to take control over which devices to exclude from using
// the OpenSL ES audio output path
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized void setBlacklistDeviceForOpenSLESUsage(boolean enable) {
blacklistDeviceForOpenSLESUsageIsOverridden = true;
blacklistDeviceForOpenSLESUsage = enable;
}
// Call these methods to override the default mono audio modes for the specified direction(s)
// (input and/or output).
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@ -204,19 +190,7 @@ class WebRtcAudioManager {
return (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION);
}
@CalledByNative
private static boolean isDeviceBlacklistedForOpenSLESUsage() {
boolean blacklisted = blacklistDeviceForOpenSLESUsageIsOverridden
? blacklistDeviceForOpenSLESUsage
: WebRtcAudioUtils.deviceIsBlacklistedForOpenSLESUsage();
if (blacklisted) {
Logging.d(TAG, Build.MODEL + " is blacklisted for OpenSL ES usage!");
}
return blacklisted;
}
// Returns true if low-latency audio output is supported.
@CalledByNative
public static boolean isLowLatencyOutputSupported(Context context) {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
}
@ -224,7 +198,6 @@ class WebRtcAudioManager {
// Returns true if low-latency audio input is supported.
// TODO(henrika): remove the hardcoded false return value when OpenSL ES
// input performance has been evaluated and tested more.
@CalledByNative
public static boolean isLowLatencyInputSupported(Context context) {
// TODO(henrika): investigate if some sort of device list is needed here
// as well. The NDK doc states that: "As of API level 21, lower latency

View File

@ -193,7 +193,7 @@ class WebRtcAudioTrack {
@CalledByNative
WebRtcAudioTrack(long nativeAudioTrack) {
threadChecker.checkIsOnValidThread();
threadChecker.detachThread();
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
this.nativeAudioTrack = nativeAudioTrack;
audioManager =

View File

@ -35,16 +35,6 @@ import org.webrtc.Logging;
final class WebRtcAudioUtils {
private static final String TAG = "WebRtcAudioUtils";
// List of devices where we have seen issues (e.g. bad audio quality) using
// the low latency output mode in combination with OpenSL ES.
// The device name is given by Build.MODEL.
private static final String[] BLACKLISTED_OPEN_SL_ES_MODELS = new String[] {
// It is recommended to maintain a list of blacklisted models outside
// this package and instead call
// WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true)
// from the client for devices where OpenSL ES shall be disabled.
};
// List of devices where it has been verified that the built-in effect
// bad and where it makes sense to avoid using it and instead rely on the
// native WebRTC version instead. The device name is given by Build.MODEL.
@ -207,12 +197,6 @@ final class WebRtcAudioUtils {
return Build.HARDWARE.equals("goldfish") && Build.BRAND.startsWith("generic_");
}
// Returns true if the device is blacklisted for OpenSL ES usage.
public static boolean deviceIsBlacklistedForOpenSLESUsage() {
List<String> blackListedModels = Arrays.asList(BLACKLISTED_OPEN_SL_ES_MODELS);
return blackListedModels.contains(Build.MODEL);
}
// Information about the current build, taken from system properties.
static void logDeviceInfo(String tag) {
Logging.d(tag,