rpms/system-config-soundcard/devel system-config-soundcard-1.2.12-mod2.patch, NONE, 1.1 system-config-soundcard.spec, 1.16, 1.17

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Aug 1 14:34:26 UTC 2005


Author: stransky

Update of /cvs/dist/rpms/system-config-soundcard/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv20223

Modified Files:
	system-config-soundcard.spec 
Added Files:
	system-config-soundcard-1.2.12-mod2.patch 
Log Message:
- moved /usr/bin/alsaunmute and /usr/bin/alsacard to /bin
- removed default_card (#134317)
- added sorting for cards
- added HW/SW config switch
- added log file (/root/scsound.log)
- added dialog for default audio device
- set non-blocking mode for aplay



system-config-soundcard-1.2.12-mod2.patch:
 soundcard.py            |  107 ++++++++++++++++++++++++++--------
 soundcardBackend.py     |  148 ++++++++++++++++++++++++++++++++++--------------
 system-config-soundcard |    6 +
 3 files changed, 194 insertions(+), 67 deletions(-)

--- NEW FILE system-config-soundcard-1.2.12-mod2.patch ---
--- system-config-soundcard-1.2.12/src/soundcard.py.old	2005-08-01 15:37:33.000000000 +0200
+++ system-config-soundcard-1.2.12/src/soundcard.py	2005-08-01 15:57:26.000000000 +0200
@@ -24,6 +24,7 @@
 import sys
 import os
 import time
+import commands
 sys.path.append('/usr/share/system-config-soundcard/')
 import soundcardBackend
 
@@ -56,7 +57,6 @@
     def __init__(self, doDebug=None, backend=None):
         self.doDebug = doDebug
 
-        self.default_card = ""
         if backend == None:
             self.soundcardBackend = soundcardBackend.soundcardBackend()
         else:
@@ -86,8 +86,6 @@
             #Kudzu has found some cards
             for card in self.cardList:
                 self.device, self.module, self.maker, self.model = self.soundcardBackend.getData(card)
-                self.default_card = self.model
-
                 self.table = gtk.Table(2, 3)
                 self.table.set_border_width(6)
                 self.table.set_col_spacings(4)
@@ -134,22 +132,23 @@
                 self.table.attach(self.module_label2, 1, 2, 2, 3, gtk.FILL, gtk.FILL)
                 self.table.attach(align, 1, 2, 3, 4)
 
+            deviceTopBox = gtk.VBox(False, 8)
 
             if len(self.cardList) == 1:
                 #There is only one card, so hide the tab and border
                 self.notebook.set_show_tabs(False)
                 self.notebook.set_show_border(False)
                 self.label = gtk.Label(_("The following audio device was detected."))
-                self.box.pack_start(self.notebook)            
 
-                self.soundcardBackend.setDefault(0)
+                self.soundcardBackend.setDefaultCard(0)
 
             else:
                 #There is more than one card, so show the primary device option menu
                 self.label = gtk.Label(_("The following audio devices were detected."))
 
-                #Create a menu
+                #Create a menu with primary card
                 deviceBox = gtk.HBox(False, 8)
+
                 self.primaryDeviceOptionMenu = gtk.OptionMenu()
                 self.primaryDeviceMenu = gtk.Menu()
 
@@ -158,17 +157,40 @@
                     item = gtk.MenuItem(self.model)
                     self.primaryDeviceMenu.append(item)
 
-                self.primaryDeviceMenu.set_active(self.cardList.index(self.soundcardBackend.getDefaultCard()))
-
+                selected_card = self.cardList.index(self.soundcardBackend.getDefaultCard())
+                self.primaryDeviceMenu.set_active(selected_card)                
                 self.primaryDeviceOptionMenu.set_menu(self.primaryDeviceMenu)
+                
+                deviceBox.pack_start(gtk.Label(_("Default audio card:")), False)
+                deviceBox.pack_start(self.primaryDeviceOptionMenu, True)
 
+		self.primaryDeviceOptionMenu.connect("changed", self.changeDefaultCard)
 
-                self.box.pack_start(self.notebook)
-                deviceBox.pack_start(gtk.Label(_("Primary audio device:")), False)
-                deviceBox.pack_start(self.primaryDeviceOptionMenu, True)
-                self.box.pack_start(deviceBox)
+                deviceTopBox.pack_start(deviceBox)
+
+            #Create a menu with primary card
+            deviceBox = gtk.HBox(False, 8)
+
+            self.primarySubDeviceOptionMenu = gtk.OptionMenu()            
+            self.refreshDeviceList()
+                        
+            deviceBox.pack_start(gtk.Label(_("Default PCM device:")), False)
+            deviceBox.pack_start(self.primarySubDeviceOptionMenu, True)
+
+            self.primarySubDeviceOptionMenu.connect("changed", self.changeDefaultDevice)
+
+            deviceTopBox.pack_start(deviceBox)
 
-		self.primaryDeviceOptionMenu.connect("changed", self.changeDefault)
+            #Create a check-box for hw/sw config
+            button = gtk.CheckButton(_("Use only the hardware device"))
+            button.set_active(self.soundcardBackend.getHardwareDevice())
+            button.connect("toggled", self.changeHW)
+            button.show()
+
+            deviceTopBox.pack_start(button)
+
+            self.box.pack_start(self.notebook)
+            self.box.pack_start(deviceTopBox)
 
         #Add icon to the top frame
         p = None
@@ -183,14 +205,56 @@
         if p:
             self.icon = gtk.Image()
             self.icon.set_from_pixbuf(p)
+            
+    def refreshDeviceList(self):
+
+        selected_card = self.soundcardBackend.getDefaultCardNum()        
+                
+        self.primarySubDeviceMenu = gtk.Menu()
 
+        comp_string = string.join(['card ',`selected_card`,':'],"")
+        comp_string_len = len(comp_string)
+        devices = commands.getoutput('/usr/bin/aplay -l')
+        devices = string.split(devices,'\n')
+            
+        self.subdevices = []
+        for line in devices:
+            if not cmp(line[:comp_string_len],comp_string):
+               dev = string.split((string.split(line,',')[1]),':')
+               self.subdevices.append([int(string.split(dev[0])[1]),(dev[1])[1:]]);
+                   
+        default = self.soundcardBackend.getDefaultDevice()
+        pos = 0
+        itm = 0
+        for sub in self.subdevices:
+            item = gtk.MenuItem(sub[1])
+            self.primarySubDeviceMenu.append(item)
+            item.show()            
+            if sub[0] == default:
+               pos = itm
+            itm += 1
+        
+        self.primarySubDeviceMenu.set_active(pos)
+        self.primarySubDeviceOptionMenu.set_menu(self.primarySubDeviceMenu)
+        self.primarySubDeviceOptionMenu.show()
+        
     def closeClicked(self, *args):
         self.apply()
         gtk.main_quit()
 
-    def changeDefault(self, *args):
-	i = self.primaryDeviceOptionMenu.get_history()
-	self.soundcardBackend.setDefault(i)
+    def changeDefaultCard(self, *args):
+        self.soundcardBackend.setDefaultCard(self.primaryDeviceOptionMenu.get_history())
+        self.soundcardBackend.setDefaultDevice(0)
+        self.soundcardBackend.writeConfig()
+        self.refreshDeviceList()
+
+    def changeDefaultDevice(self, *args):
+        self.soundcardBackend.setDefaultDevice(self.subdevices[self.primarySubDeviceOptionMenu.get_history()][0])
+        self.soundcardBackend.writeConfig()
+
+    def changeHW(self, widget, data=None):
+        self.soundcardBackend.setHardwareDevice(widget.get_active())
+        self.soundcardBackend.writeConfig()
 
     def apply(self, *args):
         if self.doDebug:
@@ -234,7 +298,9 @@
             if rc == gtk.RESPONSE_NO:
                 #Oh well, they couldn't hear the sound.  Notify the user and then quit.  We did our best
                 self.showErrorDialog(_("Automatic detection of the sound card did not work.  " \
-                                       "Audio will not be available on the system.  Please click " \
+                                       "Audio will not be available on the system.\n"  \
+                                       "You can inspect /root/scsound.log and " \
+                                       "file a new bug\nat http://bugzilla.redhat.com.\n\nPlease click " \
                                        "OK to continue."))
                 try:
                     self.mainWindow.destroy()
@@ -247,7 +313,6 @@
             #There is one sound card present.  This is the common case
             selectedCard = self.soundcardBackend.getData(self.cardList[0])
             device, module, maker, model = selectedCard
-            self.default_card = model
             return 0
 
         elif len(self.cardList) > 1:
@@ -255,7 +320,6 @@
             selectedItem = self.primaryDeviceOptionMenu.get_history()
             selectedCard = self.soundcardBackend.getData(self.cardList[selectedItem])
             device, module, maker, model = selectedCard
-            self.default_card = model
             return selectedItem
 
         else:
@@ -315,11 +379,6 @@
         self.mainWindow.show_all()
         gtk.main()
 
-    #The getData function can return the name of the setting being changed
-    #This is useful for the hardware screen in firstboot
-    def getData(self):
-        return self.default_card
-        
     def showErrorDialog(self, text):
         dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
 
--- system-config-soundcard-1.2.12/src/system-config-soundcard.old	2003-11-20 08:05:02.000000000 +0100
+++ system-config-soundcard-1.2.12/src/system-config-soundcard	2005-08-01 15:37:33.000000000 +0200
@@ -1,4 +1,8 @@
 #!/bin/sh
 
+LOG_FILE="/root/scsound.log"
+
+echo -e "------- System Config Soundcard --------\n`date`\n" > $LOG_FILE 2>&1
+
 export PYTHONPATH=/usr/share/system-config-soundcard
-/usr/bin/python2 /usr/share/system-config-soundcard/system-config-soundcard.py
+/usr/bin/python2 /usr/share/system-config-soundcard/system-config-soundcard.py >> $LOG_FILE 2>&1
--- system-config-soundcard-1.2.12/src/soundcardBackend.py.old	2005-08-01 15:37:33.000000000 +0200
+++ system-config-soundcard-1.2.12/src/soundcardBackend.py	2005-08-01 15:37:33.000000000 +0200
@@ -57,6 +57,12 @@
     return drivers
 
 ##
+## Sort fnc for box
+##
+def card_sort(card1, card2):
+    return cmp(card1.position, card2.position)
+
+##
 ## Usage
 ##
 def usage():
@@ -106,6 +112,10 @@
         self.readFile()
         self.cardList = []
         self.dspList = []
+        self.hardware_device = 0
+        self.default_device = 0
+        self.default_card = 0
+        self.readConfig()
 
     def probeCards(self):        
         driverList = read_driver_list()
@@ -124,21 +134,23 @@
         for card in list:
             if card.driver != "unknown":
                 card.position = position(driverList,card.driver)
-		self.cardList.append(card)
+                self.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":
+            if card.driver == "snd-usb-audio":
                 card.position = position(driverList,card.driver)
-	        self.cardList.append(card)
+                self.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 = position(driverList,card.driver)
-	       self.cardList.append(card)
+             if card.driver == "snd_powermac":
+                card.position = position(driverList,card.driver)
+                self.cardList.append(card)
+
+        self.cardList.sort(card_sort)
 
 	if self.cardList != []:
 	    self.defaultModule = self.cardList[0].driver
@@ -147,13 +159,13 @@
 
     def getData(self, card):
         device, module, description = card
-	if (string.count(description,"|") == 1):
+        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
+        elif (string.count(description," ") > 0):
+            maker, model = string.split(description, " ", 1)
+        else:
+            maker = description
+            model = description
 
         return device, module, maker, model
 
@@ -161,13 +173,13 @@
         self.setVolume(index)
 
         if kernel_type == '2.6':
-	    device = "plughw:%d,0"% index
+            device = "plughw:%d,0"% index
 
 	    path = "/usr/bin/aplay"
-	    args = [path,  "-D", device, "/usr/share/system-config-soundcard/sound-sample.wav"]
+	    args = [path,  "-D", device, "-N", "/usr/share/system-config-soundcard/sound-sample.wav"]
 
         if kernel_type == "2.4":
-	    if self.dspList == []:
+            if self.dspList == []:
                 device = "/dev/dsp"
             else:
                 device = "/dev/dsp%d" % self.dspList.index(module)
@@ -177,9 +189,9 @@
 
         pid = os.fork()
         if (not pid):
-	    os.execv(path, args)
-	else:
-	    os.waitpid(pid,0)
+            os.execv(path, args)
+        else:
+            os.waitpid(pid,0)
 
     def readFile(self):
         if kernel_type == '2.6':
@@ -196,12 +208,6 @@
             if (string.find(line, "sound-slot-") < 0 and string.find(line,"snd-card-") < 0) or string.strip(line)[0] == "#":
                 self.newFile.append(line)
             
-    def getDefaultCard(self):
-	try:
-	   return self.cardList[int(commands.getoutput('/usr/bin/alsacard'))]
-	except:
-	   return self.cardList[0]	   
-
     def writeFile(self, selectedCard):
         self.selectedCard = selectedCard
         aliasList = []
@@ -252,12 +258,6 @@
 
         fd.close()
 
-    def unloadModules(self):
-        for card in self.cardList:
-            device, module, maker, model = self.getData(card)
-
-            retval = os.system("/sbin/modprobe -r %s" % module)
-
     def setVolume(self, index):
         if kernel_type == '2.4':
             aumix_path = "/bin/aumix-minimal"
@@ -274,7 +274,7 @@
 
         #alsa drivers load muted. we need to set the volume for them.
         if kernel_type == '2.6':
-	    amixer_path = "/usr/bin/alsaunmute"
+	    amixer_path = "/bin/alsaunmute"
 	    amixer_pid = os.fork()
             amixer_args = [amixer_path, `index`, "-v"]
 
@@ -286,17 +286,82 @@
             else:
 	       os.waitpid(amixer_pid,0)
 
-    def setDefault(self, index):
+    def setDefaultCard(self, index):
+        self.default_card = index
+    
+    def getDefaultCard(self):
+        return self.cardList[self.default_card]
+
+    def getDefaultCardNum(self):
+        return self.default_card
+
+    def setDefaultDevice(self, index):
+        self.default_device = index        
+
+    def getDefaultDevice(self):
+        return self.default_device
+
+    def setHardwareDevice(self, state):
+        self.hardware_device = state;
+
+    def getHardwareDevice(self):
+        return self.hardware_device        
+
+    def writeConfig(self):
+
+        index = self.default_card
+        device = self.default_device
+    
         if kernel_type == '2.6':
-	     lines = []
-	     lines.append("# Generated by system-config-soundcard, do not edit by hand\n")
-             lines.append("defaults.pcm.card %d \n" % index)
-             lines.append("defaults.ctl.card %d \n" % index)
-
-	     fd = open('/etc/asound.conf', 'w')
-	     for line in lines:
-	         fd.write(line)
-	     fd.close()
+            lines = []
+
+            lines.append("#Generated by system-config-soundcard, do not edit by hand\n")
+            if self.hardware_device:            
+                lines.append("#HWCONF\n")
+                lines.append("#DEV %d\n" % device)
+                lines.append("pcm.!default { type hw card %d device %d } \n" % (index, device))
+                lines.append("ctl.!default { type hw card %d }\n" % index)
+            else:
+                lines.append("#SWCONF\n")
+                lines.append("#DEV %d\n" % device)
+                lines.append("defaults.pcm.card %d \n" %   index)
+                lines.append("defaults.pcm.device %d \n" % device)
+                lines.append("defaults.ctl.card %d \n" %   index)
+
+	    fd = open('/etc/asound.conf', 'w')
+	    for line in lines:
+	        fd.write(line)
+	    fd.close()
+
+    def readConfig(self):
+        try:            
+            fd = open('/etc/asound.conf', 'r')
+            line = fd.readline()
+            line = fd.readline()
+            self.hardware_device = (cmp(line[:7],'#HWCONF') != 1)
+
+            line = fd.readline()
+            if not cmp(line[:4],'#DEV'):
+               self.default_device = int(line[4:])
+                              
+            fd.close()
+        except:
+            self.hardware_device = 0
+            self.default_device = 0
+
+        try:
+            self.default_card = int(commands.getoutput('/bin/alsacard'))
+        except:
+            self.default_card = 0
+
+        print "Read config:\ncard %d\ndevice %d\nHW %d" % (self.default_card, self.default_device, self.hardware_device)
+
+
+    def unloadModules(self):
+        for card in self.cardList:
+            device, module, maker, model = self.getData(card)
+
+            retval = os.system("/sbin/modprobe -r %s" % module)
 
     def loadModules(self):
         retval = os.system("/sbin/modprobe %s" % self.defaultModule)
@@ -324,4 +389,3 @@
                     return self.defaultModule
 
         return 0
-


Index: system-config-soundcard.spec
===================================================================
RCS file: /cvs/dist/rpms/system-config-soundcard/devel/system-config-soundcard.spec,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- system-config-soundcard.spec	11 Jul 2005 13:14:41 -0000	1.16
+++ system-config-soundcard.spec	1 Aug 2005 14:34:23 -0000	1.17
@@ -1,7 +1,7 @@
 Summary: A graphical interface for detecting and configuring soundcards
 Name: system-config-soundcard
 Version: 1.2.12
-Release: 3
+Release: 4
 URL: http://fedora.redhat.com/projects/config-tools/redhat-config-soundcard.html
 License: GPL
 ExclusiveOS: Linux
@@ -11,6 +11,7 @@
 Source0: %{name}-%{version}.tar.bz2
 Patch0:  system-config-soundcard-1.2.12-mod.patch
 Patch1:  system-config-soundcard-1.2.12-unmute.patch
+Patch2:  system-config-soundcard-1.2.12-mod2.patch
 BuildRequires: desktop-file-utils
 BuildRequires: gettext
 ExcludeArch: s390 s390x
@@ -30,8 +31,9 @@
 
 %prep
 %setup -q
-%patch0 -p1 -b .mod
-%patch1 -p1 -b .unmute
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 make
@@ -44,6 +46,9 @@
   --add-category X-Red-Hat-Base                             \
   $RPM_BUILD_ROOT%{_datadir}/applications/system-config-soundcard.desktop
 
+mkdir -p $RPM_BUILD_ROOT/root
+touch $RPM_BUILD_ROOT/root/scsound.log
+
 %find_lang %name
 
 %clean
@@ -77,8 +82,18 @@
 %attr(0644,root,root) %{_datadir}/icons/hicolor/48x48/apps/system-config-soundcard.png
 %attr(0644,root,root) %config /etc/security/console.apps/system-config-soundcard
 %attr(0644,root,root) %config /etc/pam.d/system-config-soundcard
+%ghost /root/scsound.log
 
 %changelog
+* Wed Jul 27 2005 Martin Stransky <stransky at redhat.com 1.2.12-4
+- moved /usr/bin/alsaunmute and /usr/bin/alsacard to /bin
+- removed default_card (#134317)
+- added sorting for cards
+- added HW/SW config switch
+- added log file (/root/scsound.log)
+- added dialog for default audio device
+- set non-blocking mode for aplay
+
 * Mon Jul 11 2005 Martin Stransky <stransky at redhat.com> 1.2.12-3
 - using /usr/bin/alsaunmute for unmuting cards
 




More information about the fedora-cvs-commits mailing list