Ticket #1070: Measure.diff

File Measure.diff, 1.3 KB (added by DeanBrettle, 11 years ago)

Patch to support envs where some mixer controls (e.g. PCM and Mic) don't exist

  • audiograb.py

    diff --git a/audiograb.py b/audiograb.py
    index 801bf62..366d3b9 100644
    a b class AudioGrab_XO_1(AudioGrab): 
    292292        p = p[find(p,"Front Left:"):]
    293293        p = p[find(p,"[")+1:]
    294294        p = p[:find(p,"%]")]
    295         return int(p)
     295        try:
     296            return int(p)
     297        except:
     298            # in case alsamixer doesn't report a percentage
     299            return 0
    296300
    297301    def get_mix_for_recording(self):
    298302        """Returns True if Mix is set as recording device and False if it
    class AudioGrab_XO_1(AudioGrab): 
    410414        p = p[find(p,"Front Left:"):]
    411415        p = p[find(p,"[")+1:]
    412416        p = p[:find(p,"%]")]
    413         return int(p)
     417        try:
     418            return int(p)
     419        except:
     420            # in case alsamixer doesn't report a percentage
     421            return 0
    414422
    415423
    416424    def set_PCM_gain(self, PCM_val):
    class AudioGrab_XO_1(AudioGrab): 
    427435        p = p[find(p,"Front Left:"):]
    428436        p = p[find(p,"[")+1:]
    429437        p = p[:find(p,"%]")]
    430         return int(p)
     438        try:
     439            return int(p)
     440        except:
     441            # in case alsamixer doesn't report a percentage
     442            return 0
    431443
    432444    def set_mic_gain(self, mic_val):
    433445        """Sets the MIC gain slider settings