summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2016-05-02 14:12:59 +0100
committerRicardo Cerqueira <ricardo@cyngn.com>2016-05-02 14:12:59 +0100
commitb51931ecd0392a19f0eafd05993d20a75d24cf93 (patch)
treed1341cd15a2c6f798c8bc1c96ae4d9bf90835713
parent20b31d72dfa023e5e6af89af9167e57f6448e743 (diff)
downloadandroid_packages_apps_FMRadio-b51931ecd0392a19f0eafd05993d20a75d24cf93.tar.gz
android_packages_apps_FMRadio-b51931ecd0392a19f0eafd05993d20a75d24cf93.tar.bz2
android_packages_apps_FMRadio-b51931ecd0392a19f0eafd05993d20a75d24cf93.zip
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
-rw-r--r--res/values/config.xml19
-rw-r--r--src/com/android/fmradio/FmService.java44
2 files changed, 42 insertions, 21 deletions
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 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
// 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;
}