]> git.alsa-project.org Git - alsa.git/commitdiff
hda-analyzer: fixes for python 2.4
authorJaroslav Kysela <perex@perex.cz>
Mon, 1 Dec 2008 10:32:50 +0000 (11:32 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 1 Dec 2008 10:32:50 +0000 (11:32 +0100)
hda-analyzer/hda_analyzer.py
hda-analyzer/hda_codec.py

index c117b1dc8dd618e35e1f0c1f3a4603396c7150a5..0c76be969f8fdcc06322ec3b15add637073651d0 100755 (executable)
@@ -822,6 +822,9 @@ def main():
     print "No HDA codecs were found or insufficient priviledges for "
     print "/dev/snd/controlC* and /dev/snd/hwdepC*D* device files."
     print
+    print "You may also check, if you compiled HDA driver with HWDEP"
+    print "interface as well."
+    print
     print "Try run this program as root user."
   else:
     HDAAnalyzer()
index 01daa8d9a409b60f8ad73e78fc5002dc08d442b2..9490b5e9da762c1d2327b5971bd22a6957b03065 100644 (file)
@@ -16,12 +16,18 @@ import os
 import struct
 from fcntl import ioctl
 
-IOCTL_INFO = 0x80dc4801
-IOCTL_PVERSION = 0x80044810
-IOCTL_VERB_WRITE = 0xc0084811
-IOCTL_GET_WCAPS = 0xc0084812
+def __ioctl_val(val):
+  # workaround for OverFlow bug in python 2.4
+  if val & 0x80000000:
+    return -((val^0xffffffff)+1)
+  return val
 
-CTL_IOCTL_CARD_INFO = 0x81785501
+IOCTL_INFO = __ioctl_val(0x80dc4801)
+IOCTL_PVERSION = __ioctl_val(0x80044810)
+IOCTL_VERB_WRITE = __ioctl_val(0xc0084811)
+IOCTL_GET_WCAPS = __ioctl_val(0xc0084812)
+
+CTL_IOCTL_CARD_INFO = __ioctl_val(0x81785501)
 
 AC_NODE_ROOT   = 0
 
@@ -1056,7 +1062,10 @@ def HDA_card_list():
   result = []
   for name in listdir('/dev/snd/'):
     if name.startswith('controlC'):
-      fd = os.open("/dev/snd/%s" % name, os.O_RDONLY)
+      try:
+       fd = os.open("/dev/snd/%s" % name, os.O_RDONLY)
+      except OSError, msg:
+       continue
       info = struct.pack('ii16s16s32s80s16s80s128s', 0, 0, '', '', '', '', '', '', '')
       res = ioctl(fd, CTL_IOCTL_CARD_INFO, info)
       a = struct.unpack('ii16s16s32s80s16s80s128s', res)