mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	source/sink: Fix wrong calculation of thread_info.current_hw_volume
In pa_{source,sink}_new() and pa_{source,sink}_put() the current hardware
volume was miscalculated:
hw volume (dB) = real volume (dB) + soft volume (dB)
was used instead of
hw volume (dB) = real volume (dB) - soft volume (dB)
This lead to a crash in pa_alsa_path_set_volume() if high volumes were
set and the port was changed.
This patch fixes the calculation. Thanks to Tanu for pointing out
the correct solution.
Bug link: https://bugs.freedesktop.org/show_bug.cgi?id=65520
			
			
This commit is contained in:
		
							parent
							
								
									2417305ae7
								
							
						
					
					
						commit
						d985276c8b
					
				
					 2 changed files with 4 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -342,7 +342,7 @@ pa_sink* pa_sink_new(
 | 
			
		|||
 | 
			
		||||
    PA_LLIST_HEAD_INIT(pa_sink_volume_change, s->thread_info.volume_changes);
 | 
			
		||||
    s->thread_info.volume_changes_tail = NULL;
 | 
			
		||||
    pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 | 
			
		||||
    pa_sw_cvolume_divide(&s->thread_info.current_hw_volume, &s->real_volume, &s->soft_volume);
 | 
			
		||||
    s->thread_info.volume_change_safety_margin = core->deferred_volume_safety_margin_usec;
 | 
			
		||||
    s->thread_info.volume_change_extra_delay = core->deferred_volume_extra_delay_usec;
 | 
			
		||||
    s->thread_info.port_latency_offset = s->port_latency_offset;
 | 
			
		||||
| 
						 | 
				
			
			@ -639,7 +639,7 @@ void pa_sink_put(pa_sink* s) {
 | 
			
		|||
 | 
			
		||||
    s->thread_info.soft_volume = s->soft_volume;
 | 
			
		||||
    s->thread_info.soft_muted = s->muted;
 | 
			
		||||
    pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 | 
			
		||||
    pa_sw_cvolume_divide(&s->thread_info.current_hw_volume, &s->real_volume, &s->soft_volume);
 | 
			
		||||
 | 
			
		||||
    pa_assert((s->flags & PA_SINK_HW_VOLUME_CTRL)
 | 
			
		||||
              || (s->base_volume == PA_VOLUME_NORM
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -327,7 +327,7 @@ pa_source* pa_source_new(
 | 
			
		|||
 | 
			
		||||
    PA_LLIST_HEAD_INIT(pa_source_volume_change, s->thread_info.volume_changes);
 | 
			
		||||
    s->thread_info.volume_changes_tail = NULL;
 | 
			
		||||
    pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 | 
			
		||||
    pa_sw_cvolume_divide(&s->thread_info.current_hw_volume, &s->real_volume, &s->soft_volume);
 | 
			
		||||
    s->thread_info.volume_change_safety_margin = core->deferred_volume_safety_margin_usec;
 | 
			
		||||
    s->thread_info.volume_change_extra_delay = core->deferred_volume_extra_delay_usec;
 | 
			
		||||
    s->thread_info.port_latency_offset = s->port_latency_offset;
 | 
			
		||||
| 
						 | 
				
			
			@ -590,7 +590,7 @@ void pa_source_put(pa_source *s) {
 | 
			
		|||
 | 
			
		||||
    s->thread_info.soft_volume = s->soft_volume;
 | 
			
		||||
    s->thread_info.soft_muted = s->muted;
 | 
			
		||||
    pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 | 
			
		||||
    pa_sw_cvolume_divide(&s->thread_info.current_hw_volume, &s->real_volume, &s->soft_volume);
 | 
			
		||||
 | 
			
		||||
    pa_assert((s->flags & PA_SOURCE_HW_VOLUME_CTRL)
 | 
			
		||||
              || (s->base_volume == PA_VOLUME_NORM
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue