patch-test_ogg123_py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $OpenBSD: patch-test_ogg123_py,v 1.1.1.1 2011/05/31 09:19:45 dcoppa Exp $
  2. whrandom in python2.4 is deprecated, and in python2.5 is gone: use
  3. the 'random' module which is a drop-in replacement
  4. Use py-ao as backend
  5. (from Debian's patchset for python-pyvorbis)
  6. Use sndio as default libao backend
  7. --- test/ogg123.py.orig Mon Oct 7 01:04:59 2002
  8. +++ test/ogg123.py Tue Jun 8 08:24:59 2010
  9. @@ -17,7 +17,7 @@ import sys
  10. import string
  11. import re
  12. import os
  13. -import whrandom
  14. +import random
  15. import time
  16. import ogg.vorbis
  17. @@ -98,7 +98,7 @@ class AOPlayer(Player):
  18. def __init__(self, id=None):
  19. import ao
  20. if id is None:
  21. - id = ao.driver_id('esd')
  22. + id = ao.driver_id('sndio')
  23. self.dev = ao.AudioDevice(id)
  24. def write(self, buff, bytes):
  25. @@ -165,9 +165,10 @@ def main():
  26. sys.exit(0)
  27. elif arg == '-d' or arg == '--device':
  28. + import ao
  29. try:
  30. - driver_id = ao_get_driver_id(val)
  31. - except aoError:
  32. + driver_id = ao.driver_id(val)
  33. + except ao.aoError:
  34. sys.stderr.write('No such device %s\n' % val)
  35. sys.exit(1)
  36. @@ -188,7 +189,7 @@ def main():
  37. verbose = 0
  38. elif arg == '-z' or arg == '--shuffle':
  39. - ri = whrandom.randrange
  40. + ri = random.randrange
  41. for pos in range(len(args)):
  42. newpos = ri(pos, len(args))
  43. tmp = args[pos]
  44. @@ -199,7 +200,12 @@ def main():
  45. usage()
  46. sys.exit(0)
  47. - myplayer = choices[modchoice]() # Either AOPlayer or LADPlayer
  48. + if modchoice == 'ao' and driver_id:
  49. + playerargs = (driver_id,)
  50. + else:
  51. + playerargs = ()
  52. +
  53. + myplayer = apply(choices[modchoice],playerargs) # Either AOPlayer or LADPlayer
  54. if verbose:
  55. print "Module choice: %s" % modchoice