Skip to content

Commit 75cfcb1

Browse files
authored
Merge pull request #3844 from cmitu/mupen64plus-omx
mupen64plus: modify launch script for RPI detection
2 parents 8258090 + e440a02 commit 75cfcb1

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

scriptmodules/emulators/mupen64plus/mupen64plus.sh

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -133,37 +133,25 @@ function remap() {
133133
}
134134

135135
function setAudio() {
136-
if [[ "$(sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo)" == *BCM* ]]; then
137-
# If a raspberry pi is used try to set the right output and use audio omx if possible
138-
local audio_device=$(amixer)
139-
if [[ "$audio_device" == *PCM* ]]; then
140-
# use audio omx if we use rpi internal audio device
136+
if tr -d '\0' < /proc/device-tree/compatible | grep -Eq raspberrypi,[0-4]; then
137+
# If a Raspberry Pi is used, try to set the right output and use audio OMX if possible
138+
# check for the presence of the non-KMS audio driver
139+
if aplay -l | grep -qm1 "bcm2835 HDMI"; then
140+
# use audio OMX when the RPI has enabled the internal audio cards
141141
AUDIO_PLUGIN="mupen64plus-audio-omx"
142142
iniConfig " = " "\"" "$config"
143143
# create section if necessary
144144
if ! grep -q "\[Audio-OMX\]" "$config"; then
145145
echo "[Audio-OMX]" >> "$config"
146146
echo "Version = 1" >> "$config"
147147
fi
148-
# read output configuration
149-
local audio_port=$(amixer cget numid=3)
150-
# set output port
151-
if [[ "$audio_port" == *": values=0"* ]]; then
152-
# echo "auto configuration"
153-
# try to find the best solution
154-
local video_device=$(tvservice -s)
155-
if [[ "$video_device" == *HDMI* ]]; then
156-
iniSet "OUTPUT_PORT" "1"
157-
else
158-
iniSet "OUTPUT_PORT" "0"
159-
fi
160-
elif [[ "$audio_port" == *": values=1"* ]]; then
161-
# echo "audio jack"
162-
iniSet "OUTPUT_PORT" "0"
163-
else
164-
# echo "hdmi"
148+
# try to find which audio card is default by looking at the mixer's volume control name
149+
if amixer -Ddefault cget numid=1 | grep -qm1 HDMI; then
165150
iniSet "OUTPUT_PORT" "1"
166151
fi
152+
if amixer -Ddefault cget numid=1 | grep -qm1 Headphones; then
153+
iniSet "OUTPUT_PORT" "0"
154+
fi
167155
fi
168156
fi
169157
}
@@ -172,7 +160,7 @@ function testCompatibility() {
172160
# fallback for glesn64 and rice plugin
173161
# some roms lead to a black screen of death
174162
local game
175-
163+
176164
# these games need RSP-LLE
177165
local blacklist=(
178166
naboo
@@ -434,14 +422,13 @@ getAutoConf mupen64plus_audio && setAudio
434422
getAutoConf mupen64plus_compatibility_check && testCompatibility
435423
getAutoConf mupen64plus_texture_packs && useTexturePacks
436424

437-
if [[ "$(sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo)" == BCM* ]]; then
425+
if tr -d '\0' < /proc/device-tree/compatible | grep -Eq raspberrypi,[0-4]; then
438426
WINDOW_MODE="--windowed $RES"
439427
SDL_VIDEO_RPI_SCALE_MODE=1
440-
# If a raspberry pi is used lower resolution to 320x240 and enable SDL dispmanx scaling mode 1
441-
elif [[ -e /opt/vero3/lib/libMali.so ]]; then
428+
# If a Raspberry Pi (<5) device is used, lower resolution to 320x240 and enable SDL dispmanx scaling mode 1
429+
fi
430+
if [[ -e /opt/vero3/lib/libMali.so ]]; then
442431
SDL_AUDIODRIVER=alsa
443-
else
444-
SDL_AUDIODRIVER=pulse
445432
fi
446433

447434
SDL_AUDIODRIVER=${SDL_AUDIODRIVER} SDL_VIDEO_RPI_SCALE_MODE=${SDL_VIDEO_RPI_SCALE_MODE} "$rootdir/emulators/mupen64plus/bin/mupen64plus" --noosd $PARAMS ${WINDOW_MODE} --rsp ${RSP_PLUGIN}.so --gfx ${VIDEO_PLUGIN}.so --audio ${AUDIO_PLUGIN}.so --configdir "$configdir/n64" --datadir "$configdir/n64" "$ROM"

0 commit comments

Comments
 (0)