21 lines
778 B
Bash
21 lines
778 B
Bash
#!/usr/bin/env bash
|
||
# Conda 里 PyAudio 自带的 libportaudio 会加载同目录 libasound,从而去 conda/.../lib/alsa-lib/
|
||
# 找插件(多数环境不完整,终端刷屏且麦克风电平异常)。
|
||
# 在启动 Python **之前** 预加载系统的 libasound.so.2 可恢复正常 ALSA 行为。
|
||
#
|
||
# 用法(项目根目录):
|
||
# bash with_system_alsa.sh python src/mic_level_check.py
|
||
# bash with_system_alsa.sh python src/rocket_drone_audio.py
|
||
|
||
set -euo pipefail
|
||
ARCH="$(uname -m)"
|
||
case "${ARCH}" in
|
||
aarch64) ASO="/usr/lib/aarch64-linux-gnu/libasound.so.2" ;;
|
||
x86_64) ASO="/usr/lib/x86_64-linux-gnu/libasound.so.2" ;;
|
||
*) ASO="" ;;
|
||
esac
|
||
if [[ -n "${ASO}" && -f "${ASO}" ]]; then
|
||
export LD_PRELOAD="${ASO}${LD_PRELOAD:+:${LD_PRELOAD}}"
|
||
fi
|
||
exec "$@"
|