changeset d33a952428bc in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=d33a952428bc
description: [Zhihao Yuan] Fallback to OSS when no soundplayer found

diffstat:

 src/common/helpers.py |  11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diffs (28 lines):

diff -r 0a2ee3507b4d -r d33a952428bc src/common/helpers.py
--- a/src/common/helpers.py     Tue Apr 12 16:34:34 2011 +0200
+++ b/src/common/helpers.py     Tue Apr 12 16:36:49 2011 +0200
@@ -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 @@
             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)
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to