From 26c9da414e212c6df8b94b34849fc3ec653d3129 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Tue, 12 Apr 2011 16:36:49 +0200 Subject: [PATCH] [Zhihao Yuan] Fallback to OSS when no soundplayer found --- src/common/helpers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/helpers.py b/src/common/helpers.py index 8699544730..752dd36c13 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -51,6 +51,8 @@ try: import winsound # windows-only built-in module for playing wav import win32api import win32con + import wave # posix-only fallback wav playback + import ossaudiodev as oss except Exception: pass @@ -785,6 +787,15 @@ def play_sound_file(path_to_soundfile): pass elif os.name == 'posix': if gajim.config.get('soundplayer') == '': + def _oss_play(): + sndfile = wave.open(path_to_soundfile, 'rb') + (nc, sw, fr, nf, comptype, compname) = sndfile.getparams() + dev = oss.open('/dev/dsp', 'w') + dev.setparameters(sw * 8, nc, fr) + dev.write(sndfile.readframes(nf)) + sndfile.close() + dev.close() + gajim.thread_interface(_oss_play) return player = gajim.config.get('soundplayer') command = build_command(player, path_to_soundfile) -- GitLab