mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	alsa: disable timer-based scheduling inside a VM
In virtual machines sound card clocks and OS scheduling tend to become unreliable, adding various 'uneven' latencies. The adaptive algorithm that handles drop-outs does not handle it this well: in contrast to drop-outs on real machines that are evenly distributed, small and can easily be encountered via the adpative algorithms, drop-outs in VMs tend to happen abruptly, and massively, which is not easy to counter. This patch simply disables timer based scheduling in VMs reverting to classic IO based scheduling. This should help make PA perform better in VMs. https://bugzilla.redhat.com/show_bug.cgi?id=532775
This commit is contained in:
		
							parent
							
								
									c079ceeba0
								
							
						
					
					
						commit
						53b046d5c9
					
				
					 4 changed files with 28 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -43,6 +43,7 @@
 | 
			
		|||
#include <pulsecore/once.h>
 | 
			
		||||
#include <pulsecore/thread.h>
 | 
			
		||||
#include <pulsecore/conf-parser.h>
 | 
			
		||||
#include <pulsecore/core-rtclock.h>
 | 
			
		||||
 | 
			
		||||
#include "alsa-util.h"
 | 
			
		||||
#include "alsa-mixer.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -1308,3 +1309,26 @@ const char* pa_alsa_strerror(int errnum) {
 | 
			
		|||
 | 
			
		||||
    return translated;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pa_bool_t pa_alsa_may_tsched(pa_bool_t want) {
 | 
			
		||||
 | 
			
		||||
    if (!want)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    if (!pa_rtclock_hrtimer()) {
 | 
			
		||||
        /* We cannot depend on being woken up in time when the timers
 | 
			
		||||
        are inaccurate, so let's fallback to classic IO based playback
 | 
			
		||||
        then. */
 | 
			
		||||
        pa_log_notice("Disabling timer-based scheduling because high-resolution timers are not available from the kernel.");
 | 
			
		||||
        return FALSE; }
 | 
			
		||||
 | 
			
		||||
    if (pa_running_in_vm()) {
 | 
			
		||||
        /* We cannot depend on being woken up when we ask for in a VM,
 | 
			
		||||
         * so let's fallback to classic IO based playback then. */
 | 
			
		||||
        pa_log_notice("Disabling timer-based scheduling because running inside a VM.");
 | 
			
		||||
        return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue