Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yzyhk904 committed Apr 11, 2023
1 parent 2e8c444 commit 6ca9baa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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>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>
Expand Down Expand Up @@ -55,15 +56,4 @@ This module,

* I am not responsible for any damage that may occur to your device, so it is your own choice to attempt this module.

## Change logs

# v1.0
* Initial Release

# v1.1
* Set new properties related to an audio scheduling

# v1.2
* Added a workaround for Android 12 SELinux bug w.r.t. "ro.audio.usb.period_us" property

##
39 changes: 34 additions & 5 deletions customize-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ function makeLibraries()
mkdir -p "${MODPATH}/system/vendor/${d}"
patchMapProperty "${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}" "${MODPATH}/system/vendor/${d}/${lname}"
chmod 644 "${MODPATH}/system/vendor/${d}/${lname}"
chcon u:object_r:vendor_file:s0 "${MODPATH}/system/vendor/${d}/${lname}"
chown root:root "${MODPATH}/system/vendor/${d}/${lname}"
chmod -R a+rX "${MODPATH}/system/vendor/${d}"
if [ -z "${REPLACE}" ]; then
REPLACE="/system/vendor/${d}/${lname}"
Expand Down Expand Up @@ -232,12 +234,12 @@ function replaceSystemProps_kona()

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/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=3500/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=3500/' \
"$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/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=3500/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=3500/' \
"$MODPATH/system.prop-workaround"

fi
Expand Down Expand Up @@ -333,6 +335,8 @@ function deSpatializeAudioPolicyConfig()
touch "$modConfigXML"
stopSpatializer "$mirrorConfigXML" "$modConfigXML"
chmod 644 "$modConfigXML"
chcon u:object_r:vendor_configs_file:s0 "$modConfigXML"
chown root:root "$modConfigXML"
chmod -R a+rX "$MODPATH/system/vendor/etc"
if [ -z "$REPLACE" ]; then
REPLACE="/system${configXML}"
Expand All @@ -341,4 +345,29 @@ function deSpatializeAudioPolicyConfig()
fi
fi
fi
}
}

function disableMotoDolby()
{
local MotoApps="
/system_ext/priv-app/MotoDolbyDax3
/system_ext/priv-app/MotorolaSettingsProvider
/system_ext/priv-app/daxService
/system_ext/app/MotoSignatureApp
"
local MAGISKPATH="$(magisk --path)"
local dir mdir

for dir in $MotoApps; do
if [ -d "${MAGISKPATH}/.magisk/mirror${dir}" ]; then
mdir="${MODPATH}/system${dir}"
mkdir -p "$mdir"
chmod a+rx "$mdir"
if [ -z "$REPLACE" ]; then
REPLACE="/system${dir}"
else
REPLACE="${REPLACE} /system${dir}"
fi
fi
done
}
5 changes: 5 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
. "$MODPATH/customize-functions.sh"

REPLACE=""

# making patched ALSA utility 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"
# disabling pre-installed Moto Dolby faetures for reducing very large jitter caused by them
disableMotoDolby

if "$IS64BIT"; then
board="`getprop ro.board.platform`"
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.2.4
versionCode=1204
version=v1.3.0
versionCode=1300
author=zyhk
description=Setting audio misc. configuration values (e.g. 100 volume steps, raising the resampling quality, disabling the effects framework, etc.)

0 comments on commit 6ca9baa

Please sign in to comment.