]> git.alsa-project.org Git - alsa.git/commitdiff
hda-analyzer: Add possibility to get alsa-info.sh directly from web
authorJaroslav Kysela <perex@perex.cz>
Thu, 28 Jan 2010 12:35:30 +0000 (13:35 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 28 Jan 2010 12:37:15 +0000 (13:37 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
hda-analyzer/hda_analyzer.py
hda-analyzer/hda_proc.py

index 406cf117ae2ea13882c55c4bb37d7b46bf13f56c..0e4d04d3714b9d7df5176bc458ecffd99fb64419 100755 (executable)
@@ -19,9 +19,12 @@ Usage: hda_analyzer [[codec_proc] ...]
 
     codec_proc might specify multiple codec files per card:
         codec_proc_file1+codec_proc_file2
-    or codec_proc file might be a dump from alsa-info.sh
+    or codec_proc might be a dump from alsa-info.sh
+    or codec_proc might be a hash for codec database at www.alsa-project.org
+    or codec_proc might be a URL for codec dump or alsa-info.sh dump
 """
 
+import os
 import sys
 import gobject
 import gtk
@@ -37,6 +40,20 @@ from hda_proc import DecodeProcFile, HDACodecProc
 CODEC_TREE = {}
 DIFF_TREE = {}
 
+def gethttpfile(url, size=1024*1024):
+  from urllib import splithost
+  from httplib import HTTP
+  if not url.startswith('http:'):
+    raise ValueError, "URL %s" % url
+  host, selector = splithost(url[5:])
+  h = HTTP(host)
+  h.putrequest('GET', url)
+  h.endheaders()
+  h.getreply()
+  res = h.getfile().read(size)
+  h.close()
+  return res
+
 def read_nodes2(card, codec):
   try:
     c = HDACodec(card, codec)
@@ -74,7 +91,12 @@ def read_nodes(proc_files):
     a = f.split('+')
     idx = 0
     if len(a) == 1:
-      proc_file = DecodeProcFile(a[0])
+      if a[0].startswith('http://'):
+        proc_file = gethttpfile(a[0])
+      elif len(a[0]) == 40 and not os.path.exists(a[0]):
+        proc_file = gethttpfile('http://www.alsa-project.org/db/?f=' + a[0])
+      else:
+        proc_file = DecodeProcFile(a[0])
       if proc_file.find("ALSA Information Script") > 0:
         a = []
         pos = proc_file.find('HDA-Intel Codec information')
index ab911ddd08956c09dac149a1bf77557979c9be5f..935cfb4c490fb56f59ed09ef64e9342b67dce2a8 100644 (file)
@@ -300,7 +300,12 @@ class ProcNode(HDABaseProc):
 
   def add_connection(self, line, conn):
     line, count = self.decodeintw(line)
-    conn = conn.strip()
+    res = 0
+    if conn.startswith('    '):
+      conn = conn.strip()
+      res = 1
+    else:
+      conn = ''
     conns = []
     sel = -1
     while len(conn):
@@ -312,6 +317,7 @@ class ProcNode(HDABaseProc):
       self.wrongfile('connections %s != %s' % (count, len(conns)))
     self.connections = conns
     self.add_verb(VERBS['GET_CONNECT_SEL'], sel)
+    return res
     
   def add_unsolicited(self, line):
     line, tag = self.decodeintw(line, 'tag=')
@@ -526,8 +532,7 @@ class HDACodecProc(HDACodec, HDABaseProc):
         elif line.startswith('  Amp-Out vals: '):
           node.add_ampvals(line[17:], HDA_OUTPUT) 
         elif line.startswith('  Connection: '):
-          node.add_connection(line[13:], lines[idx+1])
-          idx += 1
+          idx += node.add_connection(line[13:], lines[idx+1])
         elif line == '  PCM:':
           node.add_pcm(lines[idx+1], lines[idx+2], lines[idx+3])
           idx += 3
@@ -545,6 +550,8 @@ class HDACodecProc(HDACodec, HDABaseProc):
           pass
         elif line.startswith('    Misc = '):
           pass
+        elif line.startswith('  Delay: '):
+          pass
         elif line.startswith('  Pin-ctls: '):
           node.add_pinctls(line[12:])
         elif line.startswith('  EAPD '):