Commit 26c9da41 authored by Yann Leboulanger's avatar Yann Leboulanger

[Zhihao Yuan] Fallback to OSS when no soundplayer found

parent 6773c63c
......@@ -51,6 +51,8 @@
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment