Viewing file: soundcardBackendKudzu.py (5.34 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
## soundcardBackendKudzu.py - Contains the backend code needed for system-config-soundcard ## Copyright (C) 2002, 2003 Red Hat, Inc. ## Copyright (C) 2002, 2003 Brent Fox <bfox@redhat.com> ## Copyright (C) 2004, 2005 Bastien Nocera <hadess@hadess.net>
## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version.
## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import string import kudzu import os import sys
import soundcardBackendSoundCard
## ## I18N ## from rhpl.translate import _, N_ import rhpl.translate as translate translate.textdomain ("system-config-soundcard")
class soundcardBackendKudzu: def __init__(self): self.doDebug = False def destroy(self, args): return
# ------------------------------------------------------------------------ # Probe routines # ------------------------------------------------------------------------ def read_driver_list(self): try: fd = open('/proc/asound/modules', 'r') list = fd.readlines() fd.close() except: return []
drivers = [] for line in list: tmp = line.split() drivers.append([int(tmp[0]), string.replace(tmp[1],'_','-')]) return drivers
def find_driver(self, list, driver): for rec in list: if rec[1] == driver: return rec[0]
return None
def probeCards(self, default_card, default_device, card_list, card_max): driverList = self.read_driver_list() list = kudzu.probe(kudzu.CLASS_AUDIO, kudzu.BUS_PCI | kudzu.BUS_MACIO, kudzu.PROBE_ALL) if self.doDebug : print "------- kudzu -----------" print list print "------- ***** -----------" cardList = []
for card in list: #Let's go through the list of cards. If the driver is 'unknown', #don't put the card in the list. if card.driver != "unknown": card.position = self.find_driver(driverList,card.driver) cardList.append(card)
# Same thing with ISA cards list = kudzu.probe(kudzu.CLASS_AUDIO, kudzu.BUS_ISAPNP, kudzu.PROBE_ALL) for card in list: if card.driver != "unknown": card.position = self.find_driver(driverList,card.driver) cardList.append(card)
# Only add USB audio devices that have snd-usb-audio as the driver list = kudzu.probe(kudzu.CLASS_AUDIO, kudzu.BUS_USB, kudzu.PROBE_ALL) for card in list: if card.driver == "snd-usb-audio": card.position = self.find_driver(driverList,card.driver) cardList.append(card)
# Same with Mac sound devices list = kudzu.probe(kudzu.CLASS_AUDIO, kudzu.BUS_MACIO, kudzu.PROBE_ALL) for card in list: if card.driver == "snd_powermac": card.position = self.find_driver(driverList,card.driver) cardList.append(card) free_cards = [] for tmp in cardList: card = soundcardBackendSoundCard.soundCard(tmp.position) device, module, description = tmp if (string.count(description,"|") == 1): maker, model = string.split(description, "|") elif (string.count(description," ") > 0): maker, model = string.split(description, " ", 1) else: maker = description model = description if self.doDebug: print "------------ Kudzu -------------" print card print "------------ tmp -------------" print tmp print "------------ description -------------" print description print "------------ ***** -------------" card.active = True card.driver = module card.type = card.maker = maker card.model = model # Card configuration card.device_list = card.loadCardDevices() if card.index != None and card.index < card_max : card_list[card.index] = card else: free_cards.append(card) card_list[default_card].default_device = default_device for num in range(card_max-1): if free_cards == []: break; if not card_list[num].active: card_list[num] = free_cards[0] card_list[num].index = num del free_cards[0]
return card_list
|