FmService: Make usage of audiopatch a build-time option
Change Ib732c8e8328035d2b3e60b7823446d1d75b3c107 assumes all devices
have issues with direct volume configuration and require audiopatching
to be disabled in favor of soft rendering. Don't do that, make it
configurable.
Change-Id: Ia334052043a292d37b44e727769232e55a673d35
diff --git a/res/values/config.xml b/res/values/config.xml
new file mode 100644
index 0000000..b587355
--- /dev/null
+++ b/res/values/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 CyanogenMod
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <bool name="config_useSoftwareRenderingForAudio" translatable="false">true</bool>
+</resources>
diff --git a/src/com/android/fmradio/FmService.java b/src/com/android/fmradio/FmService.java
index 4980c0b..d5297a5 100644
--- a/src/com/android/fmradio/FmService.java
+++ b/src/com/android/fmradio/FmService.java
@@ -1683,32 +1683,34 @@
// Make sure patches count will not be 0
private boolean isPatchMixerToEarphone(ArrayList<AudioPatch> patches) {
- /*
int deviceCount = 0;
int deviceEarphoneCount = 0;
- for (AudioPatch patch : patches) {
- AudioPortConfig[] sources = patch.sources();
- AudioPortConfig[] sinks = patch.sinks();
- AudioPortConfig sourceConfig = sources[0];
- AudioPortConfig sinkConfig = sinks[0];
- AudioPort sourcePort = sourceConfig.port();
- AudioPort sinkPort = sinkConfig.port();
- Log.d(TAG, "isPatchMixerToEarphone " + sourcePort + " ====> " + sinkPort);
- if (sourcePort instanceof AudioMixPort && sinkPort instanceof AudioDevicePort) {
- deviceCount++;
- int type = ((AudioDevicePort) sinkPort).type();
- if (type == AudioSystem.DEVICE_OUT_WIRED_HEADSET ||
- type == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) {
- deviceEarphoneCount++;
+ if (mContext.getResources().getBoolean(R.bool.config_useSoftwareRenderingForAudio)) {
+ Log.w(TAG, "FIXME: forcing isPatchMixerToEarphone to return false. "
+ + "Software rendering will be used.");
+ return false;
+ } else {
+ for (AudioPatch patch : patches) {
+ AudioPortConfig[] sources = patch.sources();
+ AudioPortConfig[] sinks = patch.sinks();
+ AudioPortConfig sourceConfig = sources[0];
+ AudioPortConfig sinkConfig = sinks[0];
+ AudioPort sourcePort = sourceConfig.port();
+ AudioPort sinkPort = sinkConfig.port();
+ Log.d(TAG, "isPatchMixerToEarphone " + sourcePort + " ====> " + sinkPort);
+ if (sourcePort instanceof AudioMixPort && sinkPort instanceof AudioDevicePort) {
+ deviceCount++;
+ int type = ((AudioDevicePort) sinkPort).type();
+ if (type == AudioSystem.DEVICE_OUT_WIRED_HEADSET ||
+ type == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) {
+ deviceEarphoneCount++;
+ }
}
}
+ if (deviceEarphoneCount == 1 && deviceCount == deviceEarphoneCount) {
+ return true;
+ }
}
- if (deviceEarphoneCount == 1 && deviceCount == deviceEarphoneCount) {
- return true;
- }
- */
- Log.w(TAG, "FIXME: forcing isPatchMixerToEarphone to return false. "
- + "Software rendering will be used.");
return false;
}