Skip to content

Commit 0bf6208

Browse files
committed
v3.5
1 parent 25796f3 commit 0bf6208

File tree

3 files changed

+70
-66
lines changed

3 files changed

+70
-66
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ AudModLib is a compatibility framework that allows the seamless integration of m
33
To uninstall, REMOVE WITH MAGISK MANAGER
44

55
## Change Log
6+
### v3.5 - 4.22.2020
7+
* Fixed bug with proxy effect patching
8+
69
### v3.4 - 4.9.2020
710
* Fix perms
811
* Bug fixes

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=aml
22
name=Audio Modification Library
3-
version=v3.4
4-
versionCode=53
3+
version=v3.5
4+
versionCode=54
55
author=zackptg5, ahrion
66
description=AudModLib is a framework that allows the seamless integration of multiple audio mods in Magisk.
77
support=https://forum.xda-developers.com/apps/magisk/module-audio-modification-library-t3579612

post-fs-data.sh

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ osp_detect() {
5656
return 0
5757
}
5858
patch_cfgs() {
59-
local first=true file lib=false effect=false outsp=false proxy=false replace=false libname libpath effname uid libname_sw uid_sw libname_hw uid_hw libpathsw libpathhw conf xml
60-
local files=$(find $MODPATH/system -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml")
61-
local opt=`getopt :leoqpr "$@"`
59+
local first=true files="" file lib=false effect=false outsp=false proxy=false replace=false libname libpath effname uid libname_sw uid_sw libname_hw uid_hw libpathsw libpathhw conf xml
60+
local opt=`getopt :fleoqpr "$@"`
6261
eval set -- "$opt"
6362
while true; do
6463
case "$1" in
64+
-f) files="placeholder"; shift;;
6565
-l) lib=true; first=false; shift;;
6666
-e) effect=true; first=false; shift;;
6767
-o) outsp=true; conf=output_session_processing; xml=postprocess; first=false; shift;;
@@ -72,6 +72,7 @@ patch_cfgs() {
7272
*) return 1;;
7373
esac
7474
done
75+
[ -z "$files" ] && files=$(find $MODPATH/system -type f -name "*audio_effects*.conf" -o -name "*audio_effects*.xml") || { files="$1"; shift; }
7576
$first && { lib=true; effect=true; }
7677
if $proxy; then
7778
effname=$1; uid=${2:?}; shift 2
@@ -96,43 +97,43 @@ patch_cfgs() {
9697
fi
9798
[ ! "$(sed -n "/^effects {/,/^}/ {/^ $effname {/,/^ }/p}" $file)" ] && sed -i "s/^effects {/effects {\n $effname {\n library proxy\n uuid $uid\n\n libsw {\n library $libname_sw\n uuid $uid_sw\n }\n\n libhw {\n library $libname_hw\n uuid $uid_hw\n }\n }/g" $file
9899
if $lib; then
99-
patch_cfgs -l "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
100+
patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
100101
if $replace; then
101-
patch_cfgs -rl "$file" "$libname_sw" "$libpathsw"
102-
patch_cfgs -rl "$file" "$libname_hw" "$libpathhw"
102+
patch_cfgs -frl "$file" "$libname_sw" "$libpathsw"
103+
patch_cfgs -frl "$file" "$libname_hw" "$libpathhw"
103104
else
104-
patch_cfgs -l "$file" "$libname_sw" "$libpathsw"
105-
patch_cfgs -l "$file" "$libname_hw" "$libpathhw"
105+
patch_cfgs -fl "$file" "$libname_sw" "$libpathsw"
106+
patch_cfgs -fl "$file" "$libname_hw" "$libpathhw"
106107
fi
107108
fi
108-
return
109-
fi
110-
if $lib; then
111-
if $replace && [ "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ]; then
112-
spaces=$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/p}" $file | sed -r "s/( *).*/\1/")
113-
sed -i "/^libraries {/,/^}/ {/^$spaces$libname {/,/^$spaces}/d}" $file
114-
fi
115-
[ ! "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ] && sed -i "s|^libraries {|libraries {\n $libname {\n path $libpath\n }|" $file
116-
fi
117-
if $effect; then
118-
if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ]; then
119-
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/")
120-
sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file
109+
else
110+
if $lib; then
111+
if $replace && [ "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ]; then
112+
spaces=$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/p}" $file | sed -r "s/( *).*/\1/")
113+
sed -i "/^libraries {/,/^}/ {/^$spaces$libname {/,/^$spaces}/d}" $file
114+
fi
115+
[ ! "$(sed -n "/^libraries {/,/^}/ {/^ *$libname {/,/}/p}" $file)" ] && sed -i "s|^libraries {|libraries {\n $libname {\n path $libpath\n }|" $file
121116
fi
122-
[ ! "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ] && sed -i "s|^effects {|effects {\n $effname {\n library $libname\n uuid $uid\n }|" $file
123-
fi
124-
if $outsp && [ "$API" -ge 26 ]; then
125-
local OIFS=$IFS; local IFS=','
126-
for i in $type; do
127-
if [ ! "$(sed -n "/^$conf {/,/^}/p" $file)" ]; then
128-
echo -e "\n$conf {\n $i {\n $effname {\n }\n }\n}" >> $file
129-
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/p}" $file)" ]; then
130-
sed -i "/^$conf {/,/^}/ s/$conf {/$conf {\n $i {\n $effname {\n }\n }/" $file
131-
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/ {/$effname {/,/}/p}}" $file)" ]; then
132-
sed -i "/^$conf {/,/^}/ {/$i {/,/^ }/ s/$i {/$i {\n $effname {\n }/}" $file
117+
if $effect; then
118+
if $replace && [ "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ]; then
119+
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effname {/p}" $file | sed -r "s/( *).*/\1/")
120+
sed -i "/^effects {/,/^}/ {/^$spaces$effname {/,/^$spaces}/d}" $file
133121
fi
134-
done
135-
local IFS=$OIFS
122+
[ ! "$(sed -n "/^effects {/,/^}/ {/^ *$effname {/,/}/p}" $file)" ] && sed -i "s|^effects {|effects {\n $effname {\n library $libname\n uuid $uid\n }|" $file
123+
fi
124+
if $outsp && [ "$API" -ge 26 ]; then
125+
local OIFS=$IFS; local IFS=','
126+
for i in $type; do
127+
if [ ! "$(sed -n "/^$conf {/,/^}/p" $file)" ]; then
128+
echo -e "\n$conf {\n $i {\n $effname {\n }\n }\n}" >> $file
129+
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/p}" $file)" ]; then
130+
sed -i "/^$conf {/,/^}/ s/$conf {/$conf {\n $i {\n $effname {\n }\n }/" $file
131+
elif [ ! "$(sed -n "/^$conf {/,/^}/ {/$i {/,/^ }/ {/$effname {/,/}/p}}" $file)" ]; then
132+
sed -i "/^$conf {/,/^}/ {/$i {/,/^ }/ s/$i {/$i {\n $effname {\n }/}" $file
133+
fi
134+
done
135+
local IFS=$OIFS
136+
fi
136137
fi
137138
;;
138139
*.xml)
@@ -143,42 +144,42 @@ patch_cfgs() {
143144
fi
144145
[ ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" -a ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*>/,/^ *\/>/p}" $file)" ] && sed -i -e "/<effects>/ a\ <effectProxy name=\"$effname\" library=\"proxy\" uuid=\"$uid\">\n <libsw library=\"$libname_sw\" uuid=\"$uid_sw\"\/>\n <libhw library=\"$libname_hw\" uuid=\"$uid_hw\"\/>\n <\/effectProxy>" $file
145146
if $lib; then
146-
patch_cfgs -l "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
147+
patch_cfgs -fl "$file" "proxy" "$libdir/lib/soundfx/libeffectproxy.so"
147148
if $replace; then
148-
patch_cfgs -rl "$file" "$libname_sw" "$libpathsw"
149-
patch_cfgs -rl "$file" "$libname_hw" "$libpathhw"
149+
patch_cfgs -frl "$file" "$libname_sw" "$libpathsw"
150+
patch_cfgs -frl "$file" "$libname_hw" "$libpathhw"
150151
else
151-
patch_cfgs -l "$file" "$libname_sw" "$libpathsw"
152-
patch_cfgs -l "$file" "$libname_hw" "$libpathhw"
152+
patch_cfgs -fl "$file" "$libname_sw" "$libpathsw"
153+
patch_cfgs -fl "$file" "$libname_hw" "$libpathhw"
153154
fi
154155
fi
155-
return
156-
fi
157-
if $lib; then
158-
if $replace && [ "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ]; then
159-
sed -i "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/d}" $file
160-
fi
161-
[ ! "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ] && sed -i "/<libraries>/ a\ <library name=\"$libname\" path=\"$(basename $libpath)\"\/>" $file
162-
fi
163-
if $effect; then
164-
if $replace && [ "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" -o "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" ]; then
165-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/d}" $file
166-
sed -i "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/d}" $file
156+
else
157+
if $lib; then
158+
if $replace && [ "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ]; then
159+
sed -i "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/d}" $file
160+
fi
161+
[ ! "$(sed -n "/<libraries>/,/<\/libraries>/ {/^ *<library name=\"$libname\" path=\"$(basename $libpath)\"\/>/p}" $file)" ] && sed -i "/<libraries>/ a\ <library name=\"$libname\" path=\"$(basename $libpath)\"\/>" $file
167162
fi
168-
[ ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" ] && sed -i "/<effects>/ a\ <effect name=\"$effname\" library=\"$(basename $libname)\" uuid=\"$uid\"\/>" $file
169-
fi
170-
if $outsp && [ "$API" -ge 26 ]; then
171-
local OIFS=$IFS; local IFS=','
172-
for i in $type; do
173-
if [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/p" $file)" ]; then
174-
sed -i "/<\/audio_effects_conf>/i\ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>\n <\/$xml>" $file
175-
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/p}" $file)" ]; then
176-
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ s/ <$xml>/ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>/" $file
177-
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ {/^ *<apply effect=\"$effname\"\/>/p}}" $file)" ]; then
178-
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ s/<stream type=\"$type\">/<stream type=\"$type\">\n <apply effect=\"$effname\"\/>/}" $file
163+
if $effect; then
164+
if $replace && [ "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" -o "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/p}" $file)" ]; then
165+
sed -i "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/d}" $file
166+
sed -i "/<effects>/,/<\/effects>/ {/^ *<effectProxy name=\"$effname\".*>/,/^ *<\/effectProxy>/d}" $file
179167
fi
180-
done
181-
local IFS=$OIFS
168+
[ ! "$(sed -n "/<effects>/,/<\/effects>/ {/^ *<effect name=\"$effname\".*\/>/p}" $file)" ] && sed -i "/<effects>/ a\ <effect name=\"$effname\" library=\"$(basename $libname)\" uuid=\"$uid\"\/>" $file
169+
fi
170+
if $outsp && [ "$API" -ge 26 ]; then
171+
local OIFS=$IFS; local IFS=','
172+
for i in $type; do
173+
if [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/p" $file)" ]; then
174+
sed -i "/<\/audio_effects_conf>/i\ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>\n <\/$xml>" $file
175+
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/p}" $file)" ]; then
176+
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ s/ <$xml>/ <$xml>\n <stream type=\"$type\">\n <apply effect=\"$effname\"\/>\n <\/stream>/" $file
177+
elif [ ! "$(sed -n "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ {/^ *<apply effect=\"$effname\"\/>/p}}" $file)" ]; then
178+
sed -i "/^ *<$xml>/,/^ *<\/$xml>/ {/<stream type=\"$type\">/,/<\/stream>/ s/<stream type=\"$type\">/<stream type=\"$type\">\n <apply effect=\"$effname\"\/>/}" $file
179+
fi
180+
done
181+
local IFS=$OIFS
182+
fi
182183
fi
183184
;;
184185
esac

0 commit comments

Comments
 (0)