Skip to content

Commit

Permalink
reimplement osp_detect
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Aug 6, 2023
1 parent 864fafa commit 46f8ce7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions magiskmodule/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ else
fi

ui_print "- Patching system audio files"
osp_detect() {
local file="$1"
local osp=music
case $file in
*.conf)
spaces=$(sed -n "/^output_session_processing {/,/^}/ {/^ *$osp {/p}" "$fil"e | sed -r "s/( *).*/\1/")
effects=$(sed -n "/^output_session_processing {/,/^}/ {/^$spaces\$osp {/,/^$spaces}/p}" "$file" | grep -E "^$spaces +[A-Za-z]+" | sed -r "s/( *.*) .*/\1/g")
for effect in ${effects}; do
spaces=$(sed -n "/^effects {/,/^}/ {/^ *$effect {/p}" "$file" | sed -r "s/( *).*/\1/")
sed -i "/^effects {/,/^}/ {/^$spaces$effect {/,/^$spaces}/d}" "$file"
done
;;
*.xml)
effects=$(sed -n "/^ *<postprocess>$/,/^ *<\/postprocess>$/ {/^ *<stream type=\"$osp\">$/,/^ *<\/stream>$/ {/<stream type=\"$osp\">/d; /<\/stream>/d; s/<apply effect=\"//g; s/\"\/>//g; s/ *//g; p}}" "$file")
for effect in ${effects}; do
sed -i "/^\( *\)<apply effect=\"$effect\"\/>/d" "$file"
done
;;
esac
}
AUDIO_EFFECTS_FILES="$( \
find -H \
$SEARCH_ROOT/system $SEARCH_ROOT/vendor $SEARCH_ROOT/odm \
Expand All @@ -122,6 +142,7 @@ for ORIGINAL_FILE in $AUDIO_EFFECTS_FILES; do
< "$ORIGINAL_FILE" > "$FILE"
;;
esac
osp_detect "$FILE"
done
[ -z "$AUDIO_EFFECTS_FILES" ] && abort "Cant find any system audio configs!"

Expand Down

0 comments on commit 46f8ce7

Please sign in to comment.