Skip to content

Commit 6fdb9d1

Browse files
committed
Show a proper error message for linux users without portaudio installed
1 parent 308ef9a commit 6fdb9d1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

gambaterm/audio.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,20 @@ def audio_player(
7777
console: Console, speed_factor: float = 1.0
7878
) -> Iterator[AudioOut | None]:
7979
# Perform late imports
80-
# Those can fail if a linux machine doesn't have portaudio or libsamplerate
81-
# installed
8280
import samplerate
83-
import sounddevice
81+
82+
# Especially for sounddevice, as it doesn't package the portaudio library in its manylinux wheels.
83+
try:
84+
import sounddevice
85+
except OSError:
86+
raise SystemExit(
87+
"""\
88+
Audio output is not available because the PortAudio library could not be found.
89+
Please make sure you have portaudio installed.
90+
For example, on Debian-based distributions, you can run:
91+
$ sudo apt install libportaudio2
92+
Otherswise, you can use the --no-audio option to run without audio support."""
93+
)
8494

8595
input_rate = console.FPS * console.TICKS_IN_FRAME
8696
resampler = samplerate.Resampler("linear", channels=2)

0 commit comments

Comments
 (0)