mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	qpaeq: Try to load equalizer module before failing, better error messages
This fixes bug 38728 [1]. When equalizer features are unavailable in running pulseaudio daemon, try to load relevant module. If this fails, following error is printed on stderr instead of a confusing traceback: It seems that running pulseaudio does not support equalizer features and loading module-equalizer-sink module failed. Exiting... [1] https://bugs.freedesktop.org/show_bug.cgi?id=38728 Signed-off-by: Matěj Laitl <matej@laitl.cz>
This commit is contained in:
		
							parent
							
								
									7b8681de07
								
							
						
					
					
						commit
						f36148a82e
					
				
					 1 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
					@ -49,7 +49,7 @@ def connect():
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
        sys.stderr.write('There was an error connecting to pulseaudio, '
 | 
					        sys.stderr.write('There was an error connecting to pulseaudio, '
 | 
				
			||||||
                         'please make sure you have the pulseaudio dbus '
 | 
					                         'please make sure you have the pulseaudio dbus '
 | 
				
			||||||
                         'and equalizer modules loaded, exiting...\n')
 | 
					                         'module loaded, exiting...\n')
 | 
				
			||||||
        sys.exit(-1)
 | 
					        sys.exit(-1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,6 +67,8 @@ class QPaeq(QtGui.QWidget):
 | 
				
			||||||
    manager_iface='org.PulseAudio.Ext.Equalizing1.Manager'
 | 
					    manager_iface='org.PulseAudio.Ext.Equalizing1.Manager'
 | 
				
			||||||
    core_iface='org.PulseAudio.Core1'
 | 
					    core_iface='org.PulseAudio.Core1'
 | 
				
			||||||
    core_path='/org/pulseaudio/core1'
 | 
					    core_path='/org/pulseaudio/core1'
 | 
				
			||||||
 | 
					    module_name='module-equalizer-sink'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
        QtGui.QWidget.__init__(self)
 | 
					        QtGui.QWidget.__init__(self)
 | 
				
			||||||
        self.setWindowTitle('qpaeq')
 | 
					        self.setWindowTitle('qpaeq')
 | 
				
			||||||
| 
						 | 
					@ -226,9 +228,25 @@ class QPaeq(QtGui.QWidget):
 | 
				
			||||||
    #)
 | 
					    #)
 | 
				
			||||||
    def set_connection(self):
 | 
					    def set_connection(self):
 | 
				
			||||||
        self.connection=connect()
 | 
					        self.connection=connect()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.manager_obj=self.connection.get_object(object_path=self.manager_path)
 | 
					        self.manager_obj=self.connection.get_object(object_path=self.manager_path)
 | 
				
			||||||
        manager_props=dbus.Interface(self.manager_obj,dbus_interface=prop_iface)
 | 
					        manager_props=dbus.Interface(self.manager_obj,dbus_interface=prop_iface)
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
            self.sinks=manager_props.Get(self.manager_iface,'EqualizedSinks')
 | 
					            self.sinks=manager_props.Get(self.manager_iface,'EqualizedSinks')
 | 
				
			||||||
 | 
					        except dbus.exceptions.DBusException:
 | 
				
			||||||
 | 
					            # probably module not yet loaded, try to load it:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                core=self.connection.get_object(object_path=self.core_path)
 | 
				
			||||||
 | 
					                core.LoadModule(self.module_name,{},dbus_interface=self.core_iface)
 | 
				
			||||||
 | 
					                # yup, we don't need to re-create manager_obj and manager_props,
 | 
				
			||||||
 | 
					                # these are late-bound
 | 
				
			||||||
 | 
					                self.sinks=manager_props.Get(self.manager_iface,'EqualizedSinks')
 | 
				
			||||||
 | 
					            except dbus.exceptions.DBusException:
 | 
				
			||||||
 | 
					                sys.stderr.write('It seems that running pulseaudio does not support '
 | 
				
			||||||
 | 
					                                 'equalizer features and loading %s module failed.\n'
 | 
				
			||||||
 | 
					                                 'Exiting...\n' % self.module_name)
 | 
				
			||||||
 | 
					                sys.exit(-1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_callbacks(self):
 | 
					    def set_callbacks(self):
 | 
				
			||||||
        manager=dbus.Interface(self.manager_obj,dbus_interface=self.manager_iface)
 | 
					        manager=dbus.Interface(self.manager_obj,dbus_interface=self.manager_iface)
 | 
				
			||||||
        manager.connect_to_signal('ProfilesChanged',self.update_profiles)
 | 
					        manager.connect_to_signal('ProfilesChanged',self.update_profiles)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue