From 0652d930b7567096d766000dc4af6a6896fbc57c Mon Sep 17 00:00:00 2001
From: yzyhk904 <86816519+yzyhk904@users.noreply.github.com>
Date: Mon, 12 Jun 2023 20:28:00 +0900
Subject: [PATCH] Add files via upload
Reduced the jitter of Tensor device's offload driver for USB DAC's
---
README.md | 14 +++++++-------
changelog.md | 3 +++
customize-functions.sh | 38 +++++++++++++-------------------------
customize.sh | 8 ++++----
module.prop | 4 ++--
post-fs-data.sh | 4 ++--
6 files changed, 31 insertions(+), 40 deletions(-)
diff --git a/README.md b/README.md
index d08e81e..f952547 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,8 @@ This module,
raises the resampling quality of the Android OS mixer (AudioFlinger) to a very mastering quality (i.e., no resampling distortion in a real sense),
disables the effects framework of the mixer (to interface to equalizers, virtualizers, visualizers, echo cancelers, automatic gain controls, etc.) for obtaining a nearly direct low jitter audio pass,
disables the android built-in spatial audio feature (A13 or higher; especially Tensor devices) for obtaining a nearly direct low jitter audio pass too,
- disables the pre-installed Moto Dolby feature for obtaining a nearly direct low jitter audio pass too,
- adjusts a USB transfer period of the USB HAL driver (not the recently common hardware offloading USB (tunneling) driver) for directly reducing the jitter of a PLL in a DAC (even in an asynchronous mode); Use "USB_SampleRate_Changer" to switch from the usual hardware offloading USB (tunneling) driver to the USB HAL one,
+ disables pre-installed Moto Dolby features for the same as above,
+ adjusts a USB transfer period of the USB HAL driver (not the recently common hardware offloading USB (tunneling) driver, but including Tensor device's offloading USB driver) for directly reducing the jitter of a PLL in a DAC (even in an asynchronous mode); Use "USB_SampleRate_Changer" to switch from the usual hardware offloading USB (tunneling) driver to the USB HAL one,
sets a higher bitrate limit of bluetooth codec SBC (dual channel mode) for EDR 2Mbps entry class earphones (not for EDR 3Mbps performance ones, but including AV amplifiers and BT speakers),
sets an audio scheduling tunable "vendor.audio.adm.buffering.ms" "2" to reduce jitter on all audio outputs,
nullifys volume listener libraries in "soundfx" folders for disabling slight compression (maybe a peak limiter only on Qcomm devices); I recommend using "DRC remover" additionally for disabling much larger compression (DRC) if on Qcomm devices
@@ -36,11 +36,11 @@ This module,
| ---: | ---: | ---: | ---: | ---- |
| 90 | 32 | 100 | | AOSP default |
| This mod. parameters: | - | - | - | - |
- | 160 | 320 | 91 | | Low Performance under A12 |
- | 160 | 480 | 91 | | High Performance under A12 |
- | 167 | 368 | | 106 | Low Performance A12 |
- | 179 | 408 | | 99 | High Performance A12 |
- | 194 | 520 | 100 | | Galaxy S4 (USB: 44.1kHz 32bit fixed) |
+ | 160 | 320 | 91 | | Low Performance devices under A12 |
+ | 160 | 480 | 91 | | High Performance devices under A12 |
+ | 167 | 368 | | 106 | Low Performance devices for A12 and later |
+ | 179 | 408 | | 99 | High Performance devices for A12 and later |
+ | 194 | 520 | 100 | | Galaxy S4 (USB: 44.1kHz and 32bits fixed) |
| External examples: | - | - | - | - |
| 100 | 29 | | 109 | AK4493 (Sharp Roll-Off for N-fold over-sampling) |
| 120 | 35 | | 110 | ESS 9038PRO (Sharp Roll-Off for N-fold over-sampling) |
diff --git a/changelog.md b/changelog.md
index 2d379a4..50f2a06 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
## Change logs
+# v1.3.1
+* Reduced the jitter of Tensor device's offload driver for USB DAC's
+
# v1.3.0
* Fixed some SELinux related bugs for Magisk v26.0's new magic mount feature
* Diabled pre-installed Moto Dolby features for reducing large jitter caused by them
diff --git a/customize-functions.sh b/customize-functions.sh
index 459812a..3f3e843 100644
--- a/customize-functions.sh
+++ b/customize-functions.sh
@@ -36,6 +36,9 @@ function getActualConfigXML()
elif [ -e "${dir}_qssi" -a -r "${dir}_qssi/${fname}" ]; then
# OnePlus stock pattern
echo "${dir}_qssi/${fname}"
+ elif [ "${dir##*/}" = "sku_`getprop ro.board.platform`" -a -r "${dir%/*}/${fname}" ]; then
+ # OnePlus stock pattern2
+ echo "${dir%/*}/${fname}"
elif [ -r "${dir}/audio/${fname}" ]; then
# Xiaomi stock pattern
echo "${dir}/audio/${fname}"
@@ -107,7 +110,7 @@ function makeLibraries()
local d lname
for d in "lib" "lib64"; do
- for lname in "libalsautils.so" "libalsautilsv2.so"; do
+ for lname in "libalsautils.so" "libalsautilsv2.so" "audio_usb_aoc.so"; do
if [ -r "${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}" ]; then
mkdir -p "${MODPATH}/system/vendor/${d}"
patchMapProperty "${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}" "${MODPATH}/system/vendor/${d}/${lname}"
@@ -253,29 +256,8 @@ function replaceSystemProps_SDM845()
function replaceSystemProps_SDM()
{
- if [ -e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" -o -e "${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker" ]; then
- sed -i \
- -e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
- -e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
- "$MODPATH/system.prop"
- sed -i \
- -e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
- -e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
- "$MODPATH/system.prop-workaround"
-
- loosenedMessage 192kHz
-
- else
- sed -i \
- -e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2500/' \
- -e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2500/' \
- "$MODPATH/system.prop"
- sed -i \
- -e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2500/' \
- -e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2500/' \
- "$MODPATH/system.prop-workaround"
-
- fi
+ # Do nothing even if "usb-samplerate-unlocker" exists
+ :
}
function replaceSystemProps_MTK_Dimensity()
@@ -337,7 +319,7 @@ function deSpatializeAudioPolicyConfig()
chmod 644 "$modConfigXML"
chcon u:object_r:vendor_configs_file:s0 "$modConfigXML"
chown root:root "$modConfigXML"
- chmod -R a+rX "$MODPATH/system/vendor/etc"
+ chmod -R a+rX "${modConfigXML%/*}"
if [ -z "$REPLACE" ]; then
REPLACE="/system${configXML}"
else
@@ -353,6 +335,7 @@ function disableMotoDolby()
/system_ext/priv-app/MotoDolbyDax3
/system_ext/priv-app/MotorolaSettingsProvider
/system_ext/priv-app/daxService
+/system_ext/priv-app/DaxUI
/system_ext/app/MotoSignatureApp
"
local MAGISKPATH="$(magisk --path)"
@@ -360,6 +343,11 @@ function disableMotoDolby()
for dir in $MotoApps; do
if [ -d "${MAGISKPATH}/.magisk/mirror${dir}" ]; then
+ case "${dir}" in
+ /system/* )
+ dir="${dir#/system}"
+ ;;
+ esac
mdir="${MODPATH}/system${dir}"
mkdir -p "$mdir"
chmod a+rx "$mdir"
diff --git a/customize.sh b/customize.sh
index d74eeea..babac11 100644
--- a/customize.sh
+++ b/customize.sh
@@ -4,7 +4,7 @@
REPLACE=""
-# making patched ALSA utility libraries for "ro.audio.usb.period_us"
+# making patched ALSA utility and Tensor's offload libraries for "ro.audio.usb.period_us"
makeLibraries
# removing post-A13 (especially Tensor's) spatial audio flags in an audio configuration file for avoiding errors
deSpatializeAudioPolicyConfig "/vendor/etc/bluetooth_audio_policy_configuration_7_0.xml"
@@ -14,13 +14,13 @@ disableMotoDolby
if "$IS64BIT"; then
board="`getprop ro.board.platform`"
case "$board" in
- "kona" )
+ "kona" | "kalama" | "shima" | "yupik" )
replaceSystemProps_Kona
;;
- "sdm845" | "bengal" | "kalama" )
+ "sdm845" | gs* )
replaceSystemProps_SDM845
;;
- "sdm660" )
+ "sdm660" | "bengal" | "holi" )
replaceSystemProps_SDM
;;
mt68* )
diff --git a/module.prop b/module.prop
index a0d1fd2..3fa4fa7 100644
--- a/module.prop
+++ b/module.prop
@@ -1,6 +1,6 @@
id=audio-misc-settings
name=Audio misc. settings
-version=v1.3.0
-versionCode=1300
+version=v1.3.1
+versionCode=1301
author=zyhk
description=Setting audio misc. configuration values (e.g. 100 volume steps, raising the resampling quality, disabling the effects framework, etc.)
diff --git a/post-fs-data.sh b/post-fs-data.sh
index babaece..f344dc6 100644
--- a/post-fs-data.sh
+++ b/post-fs-data.sh
@@ -12,7 +12,7 @@ if [ \( -e "${MODDIR%/*/*}/modules/usb-samplerate-unlocker" -a ! -e "${MODDIR%
# If usb-samplerate-unlock exists, save related libraries elsewhere because the unlocker will do the same thing in itself.
for d in "lib" "lib64"; do
- for lname in "libalsautils.so" "libalsautilsv2.so"; do
+ for lname in "libalsautils.so" "libalsautilsv2.so" "audio_usb_aoc.so"; do
if [ -r "${MODDIR}/system/vendor/${d}/${lname}" ]; then
mkdir -p "${MODDIR}/save/vendor/${d}"
mv "${MODDIR}/system/vendor/${d}/${lname}" "${MODDIR}/save/vendor/${d}/${lname}"
@@ -24,7 +24,7 @@ else
# If usb-samplerate-unlock doesn't exist, restore related libraries from their saved folders.
for d in "lib" "lib64"; do
- for lname in "libalsautils.so" "libalsautilsv2.so"; do
+ for lname in "libalsautils.so" "libalsautilsv2.so" "audio_usb_aoc.so"; do
if [ -r "${MODDIR}/save/vendor/${d}/${lname}" -a -e "${MODDIR}/system/vendor/${d}" ]; then
mv "${MODDIR}/save/vendor/${d}/${lname}" "${MODDIR}/system/vendor/${d}/${lname}"
chmod 644 "${MODDIR}/system/vendor/${d}/${lname}"