mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	acp: Don't sync hardware volumes while UCM device is disabled
The hardware controls we track for volume and mute state can change as part of enabling or disabling the UCM device. This then triggers a re-sync of our state with the hardware controls, which can e.g. set our volume to an unwanted value as the result of enabling the device, or set a hardware control to a wrong value based on our volume while disabling the device. So these UCM-triggered changes to enable/disable the device will at best show up on user interfaces and cause confusion, but maybe even will push the hardware into an unexpected state. The volume and mute state we set from user interfaces only make sense when the devices are enabled. They should not be kept in sync with hardware for inactive UCM devices [1]. Skip the callbacks for reading and changing volume and mute state if the UCM device is disabled. This way, the volume/mute controls for sinks/sources are essentially detached from the hardware controls until the UCM device is re-enabled. [1] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/772#note_1872757 Link: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/772 Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
This commit is contained in:
		
							parent
							
								
									0bdad320cd
								
							
						
					
					
						commit
						9b9ce21b1d
					
				
					 3 changed files with 42 additions and 0 deletions
				
			
		|  | @ -1143,6 +1143,14 @@ static int read_volume(pa_alsa_device *dev) | |||
| 	uint32_t i; | ||||
| 	int res; | ||||
| 
 | ||||
| 	if (dev->ucm_context) { | ||||
| 		if (!dev->active_port) | ||||
| 			return 0; | ||||
| 		pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(dev->active_port); | ||||
| 		if (pa_alsa_ucm_port_device_status(data) <= 0) | ||||
| 			return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!dev->mixer_handle) | ||||
| 		return 0; | ||||
| 
 | ||||
|  | @ -1178,6 +1186,14 @@ static void set_volume(pa_alsa_device *dev, const pa_cvolume *v) | |||
| 	if (v != &dev->real_volume) | ||||
| 		dev->real_volume = *v; | ||||
| 
 | ||||
| 	if (dev->ucm_context) { | ||||
| 		if (!dev->active_port) | ||||
| 			return; | ||||
| 		pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(dev->active_port); | ||||
| 		if (pa_alsa_ucm_port_device_status(data) <= 0) | ||||
| 			return; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!dev->mixer_handle) | ||||
| 		return; | ||||
| 
 | ||||
|  | @ -1231,6 +1247,14 @@ static int read_mute(pa_alsa_device *dev) | |||
| 	bool mute; | ||||
| 	int res; | ||||
| 
 | ||||
| 	if (dev->ucm_context) { | ||||
| 		if (!dev->active_port) | ||||
| 			return 0; | ||||
| 		pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(dev->active_port); | ||||
| 		if (pa_alsa_ucm_port_device_status(data) <= 0) | ||||
| 			return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!dev->mixer_handle) | ||||
| 		return 0; | ||||
| 
 | ||||
|  | @ -1253,6 +1277,14 @@ static void set_mute(pa_alsa_device *dev, bool mute) | |||
| { | ||||
| 	dev->muted = mute; | ||||
| 
 | ||||
| 	if (dev->ucm_context) { | ||||
| 		if (!dev->active_port) | ||||
| 			return; | ||||
| 		pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(dev->active_port); | ||||
| 		if (pa_alsa_ucm_port_device_status(data) <= 0) | ||||
| 			return; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!dev->mixer_handle) | ||||
| 		return; | ||||
| 
 | ||||
|  |  | |||
|  | @ -2559,6 +2559,10 @@ static void ucm_port_data_free(pa_device_port *port) { | |||
|     pa_xfree(ucm_port->eld_mixer_device_name); | ||||
| } | ||||
| 
 | ||||
| long pa_alsa_ucm_port_device_status(pa_alsa_ucm_port_data *data) { | ||||
|     return ucm_device_status(data->ucm, data->device); | ||||
| } | ||||
| 
 | ||||
| #else /* HAVE_ALSA_UCM */ | ||||
| 
 | ||||
| /* Dummy functions for systems without UCM support */ | ||||
|  | @ -2615,4 +2619,8 @@ void pa_alsa_ucm_roled_stream_begin(pa_alsa_ucm_config *ucm, const char *role, p | |||
| void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir) { | ||||
| } | ||||
| 
 | ||||
| long pa_alsa_ucm_port_device_status(pa_alsa_ucm_port_data *data) { | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -292,6 +292,8 @@ struct pa_alsa_ucm_port_data { | |||
|     int eld_device; /* PCM device number */ | ||||
| }; | ||||
| 
 | ||||
| long pa_alsa_ucm_port_device_status(pa_alsa_ucm_port_data *data); | ||||
| 
 | ||||
| struct pa_alsa_ucm_volume { | ||||
|     char *mixer_elem;	/* mixer element identifier */ | ||||
|     char *master_elem;	/* master mixer element identifier */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alper Nebi Yasak
						Alper Nebi Yasak