rpms/system-config-soundcard/devel system-config-soundcard-2.0.6-reset.patch, NONE, 1.1 system-config-soundcard-2.0.6-update.patch, 1.2, 1.3 system-config-soundcard.spec, 1.59, 1.60

Martin Stransky (stransky) fedora-extras-commits at redhat.com
Tue Sep 25 15:20:17 UTC 2007


Author: stransky

Update of /cvs/pkgs/rpms/system-config-soundcard/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17937

Modified Files:
	system-config-soundcard-2.0.6-update.patch 
	system-config-soundcard.spec 
Added Files:
	system-config-soundcard-2.0.6-reset.patch 
Log Message:
* Tue Sep 25 2007 Martin Stransky <stransky at redhat.com> - 2.0.6-9
- fixed #291691 - Sound card not working gives a window with 
  invalid instructions on first boot
- rewritting configuration file option splitted to config restore 
  and config reset
- used plughw device in the hardware configuration instead of the hw



system-config-soundcard-2.0.6-reset.patch:

--- NEW FILE system-config-soundcard-2.0.6-reset.patch ---
diff -up system-config-soundcard-2.0.6/src/soundcard.py.res system-config-soundcard-2.0.6/src/soundcard.py
--- system-config-soundcard-2.0.6/src/soundcard.py.res	2007-09-25 17:06:40.000000000 +0200
+++ system-config-soundcard-2.0.6/src/soundcard.py	2007-09-25 17:06:40.000000000 +0200
@@ -235,7 +235,7 @@ class childWindow:
            #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.  " \
                                   "This audio device will not be available on the system.\n\n"  \
-                                  "You can create %s, %s on the System tab and " \
+                                  "You can find log files %s, %s and " \
                                   "file a new bug\nat http://bugzilla.redhat.com.\n\nPlease click " \
                                   "OK to continue.") % ("/root/scsconfig.log", "/root/scsrun.log"))
 
@@ -726,11 +726,18 @@ class childWindow:
         return settingsBox
 
     def create_system_page_modules_reload(self, widget):
-        self.soundcardBackend.reloadModules()
+        ret = self.soundcardBackend.reloadModules()
+	if ret:
+		self.reset_notebook()
         
     def create_system_page_rewrite_files(self,  widget):
         self.soundcardBackend.rewriteConfigFiles()
 
+    def create_system_page_reset_files(self,  widget):
+        ret = self.soundcardBackend.resetConfigFiles()
+	if ret:
+		self.reset_notebook()
+
     def create_system_page(self):
     
         table = gtk.Table(2, 3)
@@ -796,24 +803,34 @@ class childWindow:
 
         infoBox.pack_start(detectionBox, False, False)
 
-        rewrite_button = gtk.Button(_("Rewrite configuration files"))
+        rewrite_button = gtk.Button(_("Restore configuration files"))
         rewrite_button.connect("clicked", self.create_system_page_rewrite_files)
 
-        rewriteBox = gtk.HBox(False, 8)
+        reset_button = gtk.Button(_("Reset configuration files"))
+        reset_button.connect("clicked", self.create_system_page_reset_files)
+
+        rewriteBox = gtk.VBox(False, 8)
         rewriteBox.pack_start(rewrite_button, True, True)
+        rewriteBox.pack_start(reset_button, True, True)
         rewriteBox = self.create_frame(self.create_frame(rewriteBox,8),0,_("Configuration files"),gtk.SHADOW_ETCHED_IN)
 
-        infoBox.pack_start(rewriteBox, False, False)
+        infoBox.pack_start(rewriteBox, False, False)        
 
         return infoBox
 
     def refresh_notebook(self):
         self.notebook.remove_page(0)
         self.notebook.remove_page(0)
-        self.notebook.prepend_page(self.create_frame(self.create_settings_page()), gtk.Label(_("Settings")))
-        self.notebook.prepend_page(self.create_frame(self.create_test_page()), gtk.Label(_("Sound test")))
+        self.notebook.remove_page(0)
+        self.notebook.append_page(self.create_frame(self.create_test_page()), gtk.Label(_("Sound test")))
+        self.notebook.append_page(self.create_frame(self.create_settings_page()), gtk.Label(_("Settings")))
+        self.notebook.append_page(self.create_frame(self.create_system_page()), gtk.Label(_("System")))
         self.notebook.show_all()
 
+    def reset_notebook(self):
+	self.soundcardBackend.reset()
+	self.refresh_notebook()
+
     def launch(self):
     
         print "Running from first-boot..."           
@@ -839,7 +856,7 @@ class childWindow:
         print "Running from command-line..."
         
         self.firstBoot = False
-        
+ 
         self.mainWindow = gtk.Dialog()
         self.mainWindow.vbox.set_spacing(5)
         self.mainWindow.connect("destroy", self.destroy)
diff -up system-config-soundcard-2.0.6/src/soundcardBackend.py.res system-config-soundcard-2.0.6/src/soundcardBackend.py
--- system-config-soundcard-2.0.6/src/soundcardBackend.py.res	2007-09-25 17:06:40.000000000 +0200
+++ system-config-soundcard-2.0.6/src/soundcardBackend.py	2007-09-25 17:06:40.000000000 +0200
@@ -66,6 +66,21 @@ def errorDialog(text):
     return
 
 ##
+## Info message
+##
+def infoDialog(text):
+    dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, text)
+
+    dlg.set_title(_("Note"))
+    dlg.set_default_size(100, 100)
+    dlg.set_position (gtk.WIN_POS_CENTER_ON_PARENT)
+    dlg.set_border_width(2)
+    dlg.set_modal(True)
+    rc = dlg.run()
+    dlg.destroy()
+    return
+
+##
 ## Get position
 ##
 def position(list, name):
@@ -127,10 +142,7 @@ def soundCardDevice_sort(device1, device
 
 
 class soundConfiguration:
-    def __init__(self):
-    
-        self.doDebug = False
-    
+    def reset(self):
         # coundcard configuration
         self.default_card = 0
         self.default_device = 0
@@ -148,6 +160,12 @@ class soundConfiguration:
 	self.usb_cards_hack = True
 	self.usb_cards_hack_position = USB_AUDIO_POSITION
 
+
+    def __init__(self):
+    
+        self.doDebug = False
+	self.reset()    
+
     def dump(self):
         print " ----------- soundConfiguration -----------"        
         print "default_card %d" % self.default_card
@@ -201,22 +219,47 @@ class soundConfiguration:
             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)
+                lines.append("pcm.!default { type plughw card %d device %d }\n" % (index, device))
+                lines.append("ctl.!default { type plughw 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()
+                lines.append("defaults.pcm.card %d\n" %   index)
+                lines.append("defaults.pcm.device %d\n" % device)
+                lines.append("defaults.ctl.card %d\n" %   index)
+
+	    try:
+		fd = open('/etc/asound.conf', 'w')
+	    	for line in lines:
+	        	fd.write(line)
+    		fd.close()
+	    except:
+		return False
 
         return True
 
+    def resetAlsaConfig(self):
+
+	lines = []
+	lines.append("#Generated by system-config-soundcard\n")
+	lines.append("#If you edit this file, don't run system-config-soundcard,\n")
+	lines.append("#all your changes here could be lost.\n")
+	lines.append("#SWCONF\n")
+	lines.append("#DEV 0\n")
+	lines.append("defaults.pcm.card 0\n")
+	lines.append("defaults.pcm.device 0\n")
+	lines.append("defaults.ctl.card 0\n")
+
+	try:
+		fd = open('/etc/asound.conf', 'w')
+		for line in lines:
+			fd.write(line)
+		fd.close()
+	except:
+		return False
+
+	return True
+
     def cardIndexChanged(self):
         self.card_index_changed = True
         self.card_default_changed = True
@@ -288,7 +331,7 @@ class soundConfiguration:
         except:
             return False
 
-	self.readUSBDevicePosition(list)
+        self.readUSBDevicePosition(list)
 
         sound_lines = []
         modprobe = []
@@ -345,6 +388,56 @@ class soundConfiguration:
 
         return True
 
+    def resetModprobe(self):
+        
+        try:
+            fd = open('/etc/modprobe.conf', 'r')
+            list = fd.readlines()
+            fd.close()
+        except:
+            return False
+       
+	modprobe = [] 
+        for whole_line in list:
+            line = string.strip(whole_line)
+            if line == []:
+               modprobe.append(whole_line)
+               continue;
+                
+            tmp = line.split()
+            if tmp == [] or tmp[0] == [] or tmp[0][0] == '#'\
+               or tmp[1] == [] or tmp[2] == [] :
+                modprobe.append(whole_line)                
+                continue
+                
+            if tmp[0] == "install" or tmp[0] == "remove":
+                modprobe.append(whole_line)                
+                continue
+    
+            if tmp[0] != "alias" and tmp[1][:3] != "snd" and\
+               tmp[2][:9] != "snd-card-":
+                modprobe.append(whole_line)                
+                continue                
+            
+            if tmp[0] != "options" and tmp[1][:3] != "snd" and\
+               tmp[2][:5] != "index" and tmp[2][:11] != "cards_limit":
+                modprobe.append(whole_line)                
+                continue
+
+	modprobe.append("options snd cards_limit=8\n")
+	modprobe.append("alias snd-card-%d %s\n" % (self.usb_cards_hack_position, USB_AUDIO_DRIVER))
+	modprobe.append("options %s index=%d\n" % (USB_AUDIO_DRIVER, self.usb_cards_hack_position))
+
+        try:
+            os.rename('/etc/modprobe.conf', '/etc/modprobe.conf.scs')
+            fd = open('/etc/modprobe.conf', 'w')
+            fd.writelines(modprobe)
+            fd.close()
+        except:
+            return False
+
+        return True
+
     # ------------------------------------------------------------------------
     # Configuring routines - sound modules reloading
     # ------------------------------------------------------------------------
@@ -402,6 +495,9 @@ class soundConfiguration:
         
         if self.unloadModule("snd", module_list):
             errorDialog(_("Unable to remove kernel modules. You need to reboot your box for the changes to take effect."))
+	    return False
+
+	return True
         
     def loadModules(self, cardArray):
     
@@ -410,12 +506,16 @@ class soundConfiguration:
                 print card.driver
                 ret = os.spawnv(os.P_WAIT, "/sbin/modprobe", ["/sbin/modprobe", card.driver])
                 if ret:
-                    errorDialog(_("Unable to load kernel module %s. You need to reboot your box for the changes to take effect.") % card.driver)
+			errorDialog(_("Unable to load kernel module %s. You need to reboot your box for the changes to take effect.") % card.driver)
+			return False
+	return True
 
     def reloadModules(self, cardArray):
-        self.unloadModules()
-        self.loadModules(cardArray)
-        self.card_index_changed = False
+        ret = self.unloadModules()
+	if not ret:
+		return False
+        ret = self.loadModules(cardArray)
+	return ret
 
     def writeConfig(self, cardArray):
         ret_alsa = ret_mod = True
@@ -433,12 +533,22 @@ class soundConfiguration:
             if ret_alsa:
                 self.card_default_changed = False
             else:
-                errorDialog(_("Unable to write ALSA configuration files!"))
+                errorDialog(_("Unable to write ALSA configuration file %s!") % "/etc/asound.conf")
 
         return ret_mod and ret_alsa
         
 
 class soundcardBackend:
+    def reset(self):
+        # Load general configuration
+        self.soundConfig = soundConfiguration()
+
+	self.cardArray = []
+
+        # Detect cards
+        self.detectCards()
+	return	
+
     def __init__(self):
     
         self.doDebug = True        
@@ -446,12 +556,9 @@ class soundcardBackend:
         self.soundcardBackendKudzu = soundcardBackendKudzu.soundcardBackendKudzu()
         self.soundcardBackendProc = soundcardBackendProc.soundcardBackendProc()
         self.soundcardBackendHal = soundcardBackendHal.soundcardBackendHal()
-        
-        # Load general configuration
-        self.soundConfig = soundConfiguration()
-        
-        # Detect cards
-        self.detectCards()
+
+	self.reset()
+	return        
 
     def destroy(self, args):
         return        
@@ -464,6 +571,7 @@ class soundcardBackend:
         return original_array
 
     def detectCards(self):
+
         # List of all cards in system
         self.cardArray = self.mergeCards(self.probeCards(DETECTION_HAL),\
                                          self.probeCards(DETECTION_KUDZU))
@@ -491,14 +599,18 @@ class soundcardBackend:
         card_max = self.soundConfig.card_max_index + 1
         
         if method == DETECTION_KUDZU:
-            return self.soundcardBackendKudzu.probeCards(default_card,\
+            ret = self.soundcardBackendKudzu.probeCards(default_card,\
                    default_device, card_list, card_max)
         elif method == DETECTION_PROC:
-            return self.soundcardBackendProc.probeCards(default_card,\
+            ret = self.soundcardBackendProc.probeCards(default_card,\
                    default_device, card_list, card_max)
         elif method == DETECTION_HAL:
-            return self.soundcardBackendHal.probeCards(default_card,\
+            ret = self.soundcardBackendHal.probeCards(default_card,\
                    default_device, card_list, card_max)
+
+	print "ProbeCards, method = ", method
+	self.dumpCardList(ret)
+	return ret
                    
         
     # ------------------------------------------------------------------------
@@ -644,12 +756,32 @@ class soundcardBackend:
         self.soundConfig.writeConfig(self.cardArray)
     
     def reloadModules(self, *args):
-        self.soundConfig.reloadModules(self.cardArray)
+        ret = self.soundConfig.reloadModules(self.cardArray)
+        if ret:
+                infoDialog(_("Modules reload was successful."));
+	return ret
 
     def rewriteConfigFiles(self):
         self.soundConfig.rewriteModprobe(self.cardArray)
         self.soundConfig.writeAlsaConfig(self.cardArray)
 
+    def resetConfigFiles(self):
+	ret = self.soundConfig.resetModprobe()
+	if not ret:
+		errorDialog(_("Unable to reset configuration in %s") % "/etc/modprobe.conf");
+		return False
+		
+	ret = self.soundConfig.resetAlsaConfig()
+	if not ret:
+		errorDialog(_("Unable to reset configuration in %s") % "/etc/alsa/alsa.conf");
+		return False
+		
+	ret = self.soundConfig.reloadModules(self.cardArray)
+	if ret:
+		infoDialog(_("Configuration reset was successful."));
+		
+	return ret
+
     # ------------------------------------------------------------------------
     # Info routines
     # ------------------------------------------------------------------------
@@ -690,8 +822,8 @@ class soundcardBackend:
         except:
             return ""
 
-    def dumpCards(self, active_only = 0):
-        for card in self.cardArray:
+    def dumpCardList(self, list, active_only = 0):
+        for card in list:
             print "--------- Card %d --------" % card.index
             
             if active_only and not card.active:
@@ -710,3 +842,7 @@ class soundcardBackend:
             print card.device_list
 
             print "Test device %d" % card.test_sound_device
+
+    def dumpCards(self, active_only = 0):
+        self.dumpCardList(self.cardArray, active_only)
+
diff -up system-config-soundcard-2.0.6/src/soundcardBackendHal.py.res system-config-soundcard-2.0.6/src/soundcardBackendHal.py
--- system-config-soundcard-2.0.6/src/soundcardBackendHal.py.res	2007-09-25 17:06:40.000000000 +0200
+++ system-config-soundcard-2.0.6/src/soundcardBackendHal.py	2007-09-25 17:10:28.000000000 +0200
@@ -38,12 +38,14 @@ ALLOWED_TYPE = "playback"
 import soundcardBackendSoundCard
 
 class soundcardBackendHal:
+    def reset(self):
+        self.driverList = self.read_driver_list()
+        self.cards = {}
+
     def __init__(self):
     
         self.doDebug = True
-
-        self.driverList = self.read_driver_list()
-                
+               
 	try:
             self._dbusBus = dbus.SystemBus()
             self.halManagerObj = self._dbusBus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
@@ -53,9 +55,7 @@ class soundcardBackendHal:
             self.halManagerObj = []
             self.halManager = []
             self.driverList = []
-            print _("Unable to initialize D-BUS/HAL!")
-       
-        self.cards = {}
+            print _("Unable to initialize D-BUS/HAL!")      
 
     def destroy(self, args):
         return
@@ -186,6 +186,8 @@ class soundcardBackendHal:
     # Same with Mac sound devices
     #if card.bus() == "macio" and card.driver() != "snd-powermac":
     def probeCards(self, default_card, default_device, card_list, card_max):
+	
+	self.reset()
 
 	if self.halManager != []:
             udiList = self.halManager.FindDeviceByCapability("alsa")        

system-config-soundcard-2.0.6-update.patch:

Index: system-config-soundcard-2.0.6-update.patch
===================================================================
RCS file: /cvs/pkgs/rpms/system-config-soundcard/devel/system-config-soundcard-2.0.6-update.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- system-config-soundcard-2.0.6-update.patch	28 May 2007 13:17:54 -0000	1.2
+++ system-config-soundcard-2.0.6-update.patch	25 Sep 2007 15:20:15 -0000	1.3
@@ -15,32 +15,6 @@
          self.mainWindow = None
  
          self.card_list = None
-@@ -246,6 +250,25 @@
-         else:
-             self.soundcardBackend.setVolume()
- 
-+    # we need to shrink/cut every too long line
-+    def wrapLine(self, line, max_len = 30, cut = False):
-+        lines = string.split(line)
-+        
-+        lines_new = []
-+        ln = 0        
-+        
-+        for l in lines:
-+          ln = ln + len(l)
-+          if ln > max_len:
-+            if not cut:
-+              l = '\n' + l[0:]
-+              ln = len(l)
-+            else:
-+              break              
-+          lines_new.append(l)
-+          
-+        return string.join(lines_new)
-+
-     def create_frame(self, widget, border = 5, label = None, shadow = gtk.SHADOW_NONE):
-         frame = gtk.Frame(label)
-         frame.set_border_width(border)
 @@ -272,26 +295,43 @@
          maker_label2 = gtk.Label("")
  


Index: system-config-soundcard.spec
===================================================================
RCS file: /cvs/pkgs/rpms/system-config-soundcard/devel/system-config-soundcard.spec,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- system-config-soundcard.spec	25 Jul 2007 10:31:24 -0000	1.59
+++ system-config-soundcard.spec	25 Sep 2007 15:20:15 -0000	1.60
@@ -1,7 +1,7 @@
 Summary: A graphical interface for detecting and configuring soundcards
 Name: system-config-soundcard
 Version: 2.0.6
-Release: 8%{dist}
+Release: 9%{dist}
 URL: http://fedoraproject.org/wiki/SystemConfig/soundcard
 License: GPL
 ExclusiveOS: Linux
@@ -14,6 +14,7 @@
 Patch2: system-config-soundcard-no-vendor.patch
 Patch3: system-config-soundcard-2.0.6-usb-hack.patch
 Patch4: system-config-soundcard-2.0.6-desktop.patch
+Patch5: system-config-soundcard-2.0.6-reset.patch
 BuildRequires: desktop-file-utils
 BuildRequires: gettext, intltool
 ExcludeArch: s390 s390x
@@ -39,8 +40,9 @@
 %patch  -p1
 %patch1 -p1
 %patch2 -p1
-%patch3 -p1 -b .usb
+%patch3 -p1
 %patch4 -p1
+%patch5 -p1 -b .res
 
 %build
 make
@@ -90,6 +92,13 @@
 %ghost /root/scsound.log
 
 %changelog
+* Tue Sep 25 2007 Martin Stransky <stransky at redhat.com> - 2.0.6-9
+- fixed #291691 - Sound card not working gives a window with 
+  invalid instructions on first boot
+- rewritting configuration file option splitted to config restore 
+  and config reset
+- used plughw device in the hardware configuration instead of the hw
+
 * Wed Jul 25 2007 Martin Stransky <stransky at redhat.com> - 2.0.6-8
 - fixed #245875 - desktop file categories
 




More information about the fedora-extras-commits mailing list