[alsa-devel] [PATCH] hda_analyzer: don't fail to display audio selector if caps variables aren't available

Anisse Astier anisse at astier.eu
Thu May 30 14:14:07 CEST 2013

In particular, when an audio selector node has Amp-In caps: N/A, it
allows to still interact with the selector, and not have TypeError traceback
throwns because of NoneType variables.

Signed-off-by: Anisse Astier <anisse at astier.eu>
Hi Jared,

I'm not sure if this is the proper way to fix this, so please consider this a
formal report for the error thrown while parsing this node:

Node 0x22 [Audio Selector] wcaps 0x30010b: Stereo Amp-In
  Amp-In caps: N/A
  Amp-In vals:  [0x00 0x00] [0x00 0x00] [0x00 0x00] [0x00 0x00] [0x00 0x00] [0x00 0x00] [0x00 0x00]
  Connection: 7
     0x18* 0x19 0x1a 0x1b 0x1d 0x0b 0x12




 hda-analyzer/hda_guilib.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hda-analyzer/hda_guilib.py b/hda-analyzer/hda_guilib.py
index 93c85e1..62eddab 100644
--- a/hda-analyzer/hda_guilib.py
+++ b/hda-analyzer/hda_guilib.py
@@ -285,9 +285,9 @@ class NodeGui(gtk.ScrolledWindow):
       vbox = gtk.VBox(False, 0)
       if caps:
-        str =  'Offset:          %d\n' % caps.ofs
-        str += 'Number of steps: %d\n' % caps.nsteps
-        str += 'Step size:       %d\n' % caps.stepsize
+        str =  'Offset:          %s\n' % (caps.ofs if caps.ofs else "N/A")
+        str += 'Number of steps: %s\n' % (caps.nsteps if caps.nsteps else "N/A")
+        str += 'Step size:       %s\n' % (caps.stepsize if caps.stepsize else "N/A")
         str += 'Mute:            %s\n' % (caps.mute and "True" or "False")
         vbox.pack_start(self.__new_text_view(text=str), True, True, 0)
         idx = 0

More information about the Alsa-devel mailing list