Viewing file: soundcardBackendProc.py (3.14 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 os import sys
import soundcardBackendSoundCard
## ## I18N ## from rhpl.translate import _, N_ import rhpl.translate as translate translate.textdomain ("system-config-soundcard")
class soundcardBackendProc: def __init__(self): self.doDebug = True 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, position): for rec in list: if rec[0] == position: return rec[1]
return _("Unknown")
def probeCards(self, default_card, default_device, card_list, card_max): driverList = self.read_driver_list() try: fd = open('/proc/asound/cards', 'r') lines = fd.readlines() except: return card_list fd.close()
index = 0 while index+1 < len(lines): name = string.strip(lines[index]) desc = string.strip(lines[index+1]) index = index + 2 name_list = string.split(name,"[") card = soundcardBackendSoundCard.soundCard(int(name_list[0])) card.active = True desc_list = string.split(desc," at ") card.model = desc_list[0]
card.type = string.strip(string.split(name_list[1],"]")[0]) card.maker = None
# find card driver card.driver = self.find_driver(driverList, card.index)
card.device_list = card.loadCardDevices() if card.index < card_max : card_list[card.index] = card card_list[default_card].default_device = default_device
return card_list
|