Ejemplo n.º 1
0
 def get_mixer_name(self):
     """ Returns mixer name """
     try:
         if not self.mixerlist:
             return ''
         return self.mixerlist[0].name
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 2
0
 def get_mixer_name(self):
     """ Returns mixer name """
     try:
         if not self.mixerlist:
             return ''
         return self.mixerlist[0].mixer()
     except alsa.ALSAAudioError, err:
         log.exception(str(err))
Ejemplo n.º 3
0
 def get_volume(self):
     """ Get mixer volume """
     try:
         if not self.mixerlist:
             return 0
         return self.mixerlist[0].getvolume()[0]
     except alsa.ALSAAudioError, err:
         log.exception(str(err))
Ejemplo n.º 4
0
 def get_descriptors(self):
     """ Returns file descriptors """
     try:
         if not hasattr(self, 'mixer'):
             return (None, None)
         return self.mixer.poll_fds[0]
     except Exception, err:
         log.exception(str(err))
         return (None, None)
Ejemplo n.º 5
0
 def set_volume(self, volume):
     """ Set mixer volume """
     try:
         for mixer in self.mixerlist:
             mixer.setvolume(volume, self.channel)
         return True
     except alsa.ALSAAudioError, err:
         log.exception(str(err))
         return False
Ejemplo n.º 6
0
 def init_builder(self):
     """ Initialize Gtk.Builder """
     try:
         glade_file = os.path.join(RES_DIR,
                 "preferences.glade")
         self.tree = Gtk.Builder()
         self.tree.set_translation_domain(APP_NAME)
         self.tree.add_from_file(glade_file)
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 7
0
 def get_volume(self):
     """ Get mixer volume """
     try:
         min, max = self.element.get_volume_range(self.capture)
         range = max - min
         vol = self.element.get_volume(0, self.capture)
         vol -= min
         volume = int(round(vol * 100/float(range)))
         return volume
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 8
0
 def is_muted(self):
     """ Returns mixer mute status """
     global OLD_VOLUME, MUTED
     try:
         if self.element.has_switch(self.capture):
             if self.element.has_channel(0, self.capture):
                 return not self.element.get_switch(0, self.capture)
         else:
             if MUTED:
                 return True
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 9
0
 def set_volume(self, volume):
     """ Set mixer volume """
     try:
         min, max = self.element.get_volume_range(self.capture)
         range = max - min
         vol = int(round(range * (volume * .01) + min))
         for mixer in self.mixerlist:
             mixer.set_volume_all(vol, self.capture)
         return True
     except Exception, err:
         log.exception(str(err))
         return False
Ejemplo n.º 10
0
 def get_cards(self):
     """ Returns cards list """
     cards = []
     try:
         acards = alsacard.card_list()
         for card in acards:
             try:
                 self.get_mixers(card)[0]
             except IndexError:
                 cards.append(None)
             else:
                 cards.append(alsacard.card_get_name(card))
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 11
0
 def get_mixers(self, card_index=0):
     """ Returns mixers list """
     mixers = []
     try:
         mixer = alsamixer.Mixer()
         mixer.attach("hw:%d" % card_index)
         mixer.load()
         for mix in mixer.list():
             m = alsamixer.Element(mixer=mixer,
                     name=mix[0], index=0)
             if m.has_volume():
                 if mix[0] not in mixers:
                     mixers.append(mix[0])
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 12
0
 def set_mute(self, mute=0):
     """ Set mixer mute status """
     global OLD_VOLUME, MUTED
     try:
         for mixer in self.mixerlist:
             if mixer.has_switch(self.capture):
                 if mixer.has_channel(0, self.capture):
                     mixer.set_switch_all(not mute, self.capture)
         else:
             # mixer doesn't have mute switch
             if mute:
                 OLD_VOLUME = self.get_volume()
                 self.set_volume(0)
                 MUTED = True
             else:
                 self.set_volume(OLD_VOLUME)
                 MUTED = False
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 13
0
 def get_card_name(self):
     """ Returns card name """
     try:
         return alsacard.card_get_name(self.card_index)
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 14
0
 def has_capture_channel(self):
     try:
         if self.element.has_channel(0, True):
             return True
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 15
0
 def has_playback_channel(self):
     try:
         if self.element.has_channel(0):
             return True
     except Exception, err:
         log.exception(str(err))
Ejemplo n.º 16
0
 def get_card_name(self):
     """ Returns card name """
     try:
         return alsa.cards()[self.card_index]
     except IndexError, err:
         log.exception(str(err))