Add OpenSL ES enable setting to AppRTCDemo.
Disable OpenSL ES by default.
Plus remove no longer used CPU overuse detection option.
Review URL: https://codereview.webrtc.org/1449083002
Cr-Commit-Position: refs/heads/master@{#10670}
diff --git a/webrtc/examples/androidapp/res/values/strings.xml b/webrtc/examples/androidapp/res/values/strings.xml
index b3c55b4..951f65a 100644
--- a/webrtc/examples/androidapp/res/values/strings.xml
+++ b/webrtc/examples/androidapp/res/values/strings.xml
@@ -97,14 +97,14 @@
<string name="pref_noaudioprocessing_dlg">Disable audio processing pipeline.</string>
<string name="pref_noaudioprocessing_default">false</string>
+ <string name="pref_opensles_key">opensles_preference</string>
+ <string name="pref_opensles_title">Use OpenSL ES for audio playback.</string>
+ <string name="pref_opensles_dlg">Use OpenSL ES for audio playback.</string>
+ <string name="pref_opensles_default">false</string>
+
<string name="pref_miscsettings_key">misc_settings_key</string>
<string name="pref_miscsettings_title">Miscellaneous settings.</string>
- <string name="pref_cpu_usage_detection_key">cpu_usage_detection</string>
- <string name="pref_cpu_usage_detection_title">CPU overuse detection.</string>
- <string name="pref_cpu_usage_detection_dlg">Adapt transmission to CPU status.</string>
- <string name="pref_cpu_usage_detection_default" translatable="false">true</string>
-
<string name="pref_room_server_url_key">room_server_url_preference</string>
<string name="pref_room_server_url_title">Room server URL.</string>
<string name="pref_room_server_url_dlg">Enter a room server URL.</string>
diff --git a/webrtc/examples/androidapp/res/xml/preferences.xml b/webrtc/examples/androidapp/res/xml/preferences.xml
index c580e0c..8c111e0 100644
--- a/webrtc/examples/androidapp/res/xml/preferences.xml
+++ b/webrtc/examples/androidapp/res/xml/preferences.xml
@@ -94,18 +94,18 @@
android:title="@string/pref_noaudioprocessing_title"
android:dialogTitle="@string/pref_noaudioprocessing_dlg"
android:defaultValue="@string/pref_noaudioprocessing_default" />
+
+ <CheckBoxPreference
+ android:key="@string/pref_opensles_key"
+ android:title="@string/pref_opensles_title"
+ android:dialogTitle="@string/pref_opensles_dlg"
+ android:defaultValue="@string/pref_opensles_default" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/pref_miscsettings_key"
android:title="@string/pref_miscsettings_title">
- <CheckBoxPreference
- android:key="@string/pref_cpu_usage_detection_key"
- android:title="@string/pref_cpu_usage_detection_title"
- android:dialogTitle="@string/pref_cpu_usage_detection_dlg"
- android:defaultValue="@string/pref_cpu_usage_detection_default" />
-
<EditTextPreference
android:key="@string/pref_room_server_url_key"
android:title="@string/pref_room_server_url_title"
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
index 7bf4f68..06c491a 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
@@ -72,8 +72,8 @@
"org.appspot.apprtc.AUDIOCODEC";
public static final String EXTRA_NOAUDIOPROCESSING_ENABLED =
"org.appspot.apprtc.NOAUDIOPROCESSING";
- public static final String EXTRA_CPUOVERUSE_DETECTION =
- "org.appspot.apprtc.CPUOVERUSE_DETECTION";
+ public static final String EXTRA_OPENSLES_ENABLED =
+ "org.appspot.apprtc.OPENSLES";
public static final String EXTRA_DISPLAY_HUD =
"org.appspot.apprtc.DISPLAY_HUD";
public static final String EXTRA_CMDLINE =
@@ -223,7 +223,7 @@
intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0),
intent.getStringExtra(EXTRA_AUDIOCODEC),
intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false),
- intent.getBooleanExtra(EXTRA_CPUOVERUSE_DETECTION, true));
+ intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false));
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java
index 0bdaebb..9bc0b45 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java
@@ -66,7 +66,7 @@
private String keyprefAudioCodec;
private String keyprefHwCodecAcceleration;
private String keyprefNoAudioProcessingPipeline;
- private String keyprefCpuUsageDetection;
+ private String keyprefOpenSLES;
private String keyprefDisplayHud;
private String keyprefRoomServerUrl;
private String keyprefRoom;
@@ -93,7 +93,7 @@
keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
- keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
+ keyprefOpenSLES = getString(R.string.pref_opensles_key);
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
keyprefRoom = getString(R.string.pref_room_key);
@@ -258,6 +258,11 @@
keyprefNoAudioProcessingPipeline,
Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default)));
+ // Check OpenSL ES enabled flag.
+ boolean useOpenSLES = sharedPref.getBoolean(
+ keyprefOpenSLES,
+ Boolean.valueOf(getString(R.string.pref_opensles_default)));
+
// Get video resolution from settings.
int videoWidth = 0;
int videoHeight = 0;
@@ -313,12 +318,6 @@
audioStartBitrate = Integer.parseInt(bitrateValue);
}
- // Test if CpuOveruseDetection should be disabled. By default is on.
- boolean cpuOveruseDetection = sharedPref.getBoolean(
- keyprefCpuUsageDetection,
- Boolean.valueOf(
- getString(R.string.pref_cpu_usage_detection_default)));
-
// Check statistics display option.
boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud,
Boolean.valueOf(getString(R.string.pref_displayhud_default)));
@@ -342,10 +341,9 @@
intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec);
intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED,
noAudioProcessing);
+ intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES);
intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
- intent.putExtra(CallActivity.EXTRA_CPUOVERUSE_DETECTION,
- cpuOveruseDetection);
intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
intent.putExtra(CallActivity.EXTRA_CMDLINE, commandLineRun);
intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs);
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
index 8676301..3ad27d6 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java
@@ -34,6 +34,7 @@
import org.webrtc.VideoRenderer;
import org.webrtc.VideoSource;
import org.webrtc.VideoTrack;
+import org.webrtc.voiceengine.WebRtcAudioManager;
import java.util.EnumSet;
import java.util.LinkedList;
@@ -135,14 +136,14 @@
public final int audioStartBitrate;
public final String audioCodec;
public final boolean noAudioProcessing;
- public final boolean cpuOveruseDetection;
+ public final boolean useOpenSLES;
public PeerConnectionParameters(
boolean videoCallEnabled, boolean loopback,
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
String videoCodec, boolean videoCodecHwAcceleration,
int audioStartBitrate, String audioCodec,
- boolean noAudioProcessing, boolean cpuOveruseDetection) {
+ boolean noAudioProcessing, boolean useOpenSLES) {
this.videoCallEnabled = videoCallEnabled;
this.loopback = loopback;
this.videoWidth = videoWidth;
@@ -154,7 +155,7 @@
this.audioStartBitrate = audioStartBitrate;
this.audioCodec = audioCodec;
this.noAudioProcessing = noAudioProcessing;
- this.cpuOveruseDetection = cpuOveruseDetection;
+ this.useOpenSLES = useOpenSLES;
}
}
@@ -305,6 +306,14 @@
&& peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
preferIsac = true;
}
+
+ // Enable/disable OpenSL ES playback.
+ if (!peerConnectionParameters.useOpenSLES) {
+ Log.d(TAG, "Disable OpenSL ES audio");
+ WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */);
+ }
+
+ // Create peer connection factory.
if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
peerConnectionParameters.videoCodecHwAcceleration)) {
events.onPeerConnectionError("Failed to initializeAndroidGlobals");
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java
index 9ad6e4d..f3cc770 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/SettingsActivity.java
@@ -35,8 +35,8 @@
private String keyprefStartAudioBitrateValue;
private String keyPrefAudioCodec;
private String keyprefNoAudioProcessing;
+ private String keyprefOpenSLES;
- private String keyprefCpuUsageDetection;
private String keyPrefRoomServerUrl;
private String keyPrefDisplayHud;
@@ -56,8 +56,8 @@
keyprefStartAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
keyPrefAudioCodec = getString(R.string.pref_audiocodec_key);
keyprefNoAudioProcessing = getString(R.string.pref_noaudioprocessing_key);
+ keyprefOpenSLES = getString(R.string.pref_opensles_key);
- keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key);
keyPrefDisplayHud = getString(R.string.pref_displayhud_key);
@@ -90,8 +90,8 @@
setAudioBitrateEnable(sharedPreferences);
updateSummary(sharedPreferences, keyPrefAudioCodec);
updateSummaryB(sharedPreferences, keyprefNoAudioProcessing);
+ updateSummaryB(sharedPreferences, keyprefOpenSLES);
- updateSummaryB(sharedPreferences, keyprefCpuUsageDetection);
updateSummary(sharedPreferences, keyPrefRoomServerUrl);
updateSummaryB(sharedPreferences, keyPrefDisplayHud);
}
@@ -122,7 +122,7 @@
|| key.equals(keyprefCaptureQualitySlider)
|| key.equals(keyprefHwCodec)
|| key.equals(keyprefNoAudioProcessing)
- || key.equals(keyprefCpuUsageDetection)
+ || key.equals(keyprefOpenSLES)
|| key.equals(keyPrefDisplayHud)) {
updateSummaryB(sharedPreferences, key);
}
diff --git a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
index 5a5034b..58ed28a 100644
--- a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
+++ b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
@@ -22,7 +22,6 @@
import org.appspot.apprtc.util.LooperExecutor;
import org.webrtc.EglBase;
import org.webrtc.IceCandidate;
-import org.webrtc.MediaConstraints;
import org.webrtc.PeerConnection;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.SessionDescription;
@@ -252,7 +251,7 @@
new PeerConnectionParameters(
enableVideo, true, // videoCallEnabled, loopback.
0, 0, 0, 0, videoCodec, true, // video codec parameters.
- 0, "OPUS", false, true); // audio codec parameters.
+ 0, "OPUS", false, false); // audio codec parameters.
return peerConnectionParameters;
}