Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Reduced the jitter of Tensor device's offload driver for USB DAC's
  • Loading branch information
yzyhk904 authored Jun 12, 2023
1 parent fd03a05 commit 0652d93
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 40 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This module,
<li>raises the resampling quality of the Android OS mixer (AudioFlinger) to a very mastering quality (i.e., no resampling distortion in a real sense),</li>
<li>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,</li>
<li>disables the android built-in spatial audio feature (A13 or higher; especially Tensor devices) for obtaining a nearly direct low jitter audio pass too,</li>
<li>disables the pre-installed Moto Dolby feature for obtaining a nearly direct low jitter audio pass too,</li>
<li>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 <a href="https://github.com/yzyhk904/USB_SampleRate_Changer">"USB_SampleRate_Changer"</a> to switch from the usual hardware offloading USB (tunneling) driver to the USB HAL one,</li>
<li>disables pre-installed Moto Dolby features for the same as above,</li>
<li>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 <a href="https://github.com/yzyhk904/USB_SampleRate_Changer">"USB_SampleRate_Changer"</a> to switch from the usual hardware offloading USB (tunneling) driver to the USB HAL one,</li>
<li>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),</li>
<li>sets an audio scheduling tunable "vendor.audio.adm.buffering.ms" "2" to reduce jitter on all audio outputs,</li>
<li>nullifys volume listener libraries in "soundfx" folders for disabling slight compression (maybe a peak limiter only on Qcomm devices); I recommend using <a href="https://github.com/Magisk-Modules-Alt-Repo/drc-remover">"DRC remover"</a> additionally for disabling much larger compression (DRC) if on Qcomm devices</li>
Expand Down Expand Up @@ -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) |
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 13 additions & 25 deletions customize-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -353,13 +335,19 @@ 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)"
local dir mdir

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"
Expand Down
8 changes: 4 additions & 4 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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* )
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -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.)
4 changes: 2 additions & 2 deletions post-fs-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
Expand Down

0 comments on commit 0652d93

Please sign in to comment.